Converts the first character of each word in a string to uppercase
Back
rtrim()
Front
Strips whitespace from the right side of a string
Back
strnatcmp()
Front
Compares two strings using a "natural order" algorithm (case-sensitive)
Back
ltrim()
Front
Strips whitespace from the left side of a string
Back
strripos()
Front
Finds the position of the last occurrence of a string inside another string (case-insensitive)
Back
trim()
Front
Removes whitespace from both ends of a string
Back
str_ireplace()
Front
Replaces some characters in a string (case-insensitive)
Back
str_replace()
Front
Replaces some characters in a string (case-sensitive)
(find, replace, word)
Back
strtolower()
Front
Converts a string to lowercase letters
Back
isset()
Front
determine if a variable is set and is not null
Back
min()
Front
find min value
Back
str_repeat()
Front
Repeats a string a specified number of times
(string, number)
Back
strcmp()
Front
Compares two strings (case-sensitive)
(string1,string2)
Back
sqrt()
Front
square root function
Back
end()
Front
point to the last element in an array
Back
ucfirst()
Front
Converts the first character of a string to uppercase
Back
HEREDOC
Front
-Write large amounts of text from php, but without the need to constantly escape things.
- like multiline double quotes
- SYNTAX:
<<<MESSAGE
MESSAGE;
Back
round()
Front
rounds number
Back
Why tags in PHP file?
Front
Allows PHP to be embedded in all sorts of different documents, as everything outside of a pair of opening and closing tags is ignored by the PHP parser
Back
floor()
Front
round down
Back
strtoupper()
Front
Converts a string to uppercase letters
Back
unset()
Front
remove individual elements from an array
Back
strpos()
Front
- Returns the position of the first occurrence of a string inside another string (case-sensitive)
(string, find, offset(optional))
Back
define()
Front
constant declaration, in the form ('variable',value)
Back
strcasecmp()
Front
Compares two strings (case-insensitive)
Back
rand()
Front
generates random numbers
Back
lcfirst()
Front
Make a string's first character lowercase
Back
Variable Naming Rules
Front
- start with letter or underscore
- case sensitive
- alpha-numeric and underscores only
- no spaces
- no php reserved words
Back
array_values()
Front
Returns all the values of an array
Back
abs()
Front
get absolute value
Back
max()
Front
find max value
Back
PHP Variables
Front
- start with $
- "loosely typed" variable does not need to be declared before being set
- PHP automatically converts to the correct data type
Back
$arrays = array('x','x','x');
Front
array with one statement
Back
ceil()
Front
Returns the value of a number rounded upwards to the nearest integer
Back
str_shuffle()
Front
Randomly shuffles all characters in a string
Back
str_pad()
Front
pad a string to a certain length with another string
Back
empty()
Front
determine whether variable is empty:
"" - empty string
0 - 0 as an integer
0.0 - 0 as a float
"0" - 0 as a string
NULL
False
array() - empty array
Back
mt_rand()
Front
Returns a random integer using Mersenne Twister algorithm
Back
pow()
Front
exponential expression
Back
number_format()
Front
Formats a number with grouped thousands
Back
NEWDOC
Front
same as heredoc except for single quoted strings
Back
strrev()
Front
Reverses a string
Back
intval()
floatval()
Front
converts strings to number
Back
strrpos()
Front
Finds the position of the last occurrence of a string inside another string (case-sensitive)
Back
substr()
Front
- Returns a part of a string
(string, start, length)
Back
is_numeric()
Front
used to check whether variable is numeric or not. Returns boolean value
Back
strnatcasecmp()
Front
Compares two strings using a "natural order" algorithm (case-insensitive)
Back
stripos()
Front
Returns the position of the first occurrence of a string inside another string (case-insensitive)
Back
count()
Front
count all elements in an array
Back
strlen()
Front
Returns the length of a string
Back
Section 2
(29 cards)
array_unshift()
Front
Adds one or more elements to the beginning of an array
Back
array_keys()
Front
Returns all the keys of an array
Back
array_reverse()
Front
Returns an array in the reverse order
Back
array_key_exists()
Front
Checks if the specified key exists in the array
(key,array)
Back
array_pop()
Front
Deletes the last element of an array
Back
array_merge()
Front
Merges one or more arrays into one array
Back
array_shift()
Front
Removes the first element from an array, and returns the value of the removed element
Back
== vs ===
Front
only check value VS. check value and type
Back
explode()
Front
split a string by a string
(split,string)
Back
array_pad()
Front
Inserts a specified number of items, with a specified value, to an array
(array, length, value)
Back
array_push()
Front
Inserts one or more elements to the end of an array
(array,value)
Back
sort($numbers, SORT_NUMERIC)
Front
sort numbers in ascending order
Back
implode()
Front
join array elements with a string
(join, array)
Back
array_search()
Front
Searches an array for a given value and returns the key
(key or value, array)
Back
print_r()
Front
prints array
Back
array_chunk()
Front
Splits an array into chunks of arrays
(array, split size)
Back
sort()
Front
sort strings in ascending order
Back
array_fill()
Front
Fills an array with values
(start index, length, value)
Back
asort()
Front
sort associative arrays in ascending order, according to the value
Back
array_merge()
Front
Merges one or more arrays into one array
Back
ksort()
Front
sort associative arrays in ascending order, according to the key
Back
array_values()
Front
Returns all the values of an array
Back
krsort()
Front
sort associative arrays in descending order, according to the key
Back
array_unique()
Front
Removes duplicate values from an array
Back
rsort()
Front
sorts in descending order
Back
array_sum()
Front
Returns the sum of the values in an array
Back
array_slice()
Front
slice a portion of an array from a given position
(array, slice position)
Back
array_splice()
Front
removes a portion of array an replaces it with something else
(array, offset, length, replacement)
Back
arsort()
Front
sort associative arrays in descending order, according to the value