Let's say that you want to store numerous values within one variable. It may sound complex for some of you, but to those of us that use arrays daily, they are a God send. They help us to unclutter and organize our code and speed up development. How to create an array: $cars = array(1 => "Chevy", 2=> "Honda", 3=> "Mitsubishi"); PHP: Now you can use this array. $cars = array(1 => "Chevy", 2=> "Honda", 3=> "Mitsubishi"); if ($_POST['favorite'] == 2) { $favorite_car = $cars[2]; echo 'Your favorite make of car is '.$favorite_car; } PHP: This will print: *Note: Do not use quotes in the array when using the numeric key. $cars['2'] is bad. However, you can use $cars['Honda'].
is_array - Whether the specified variable is currently an array. in_array($needle, $haystack, $strict) - Whether the string $needle exists as one of the values of $haystack, if $strict is set to true, then it will only match if they are identical (===, of the same type.) Returns true if it exists (and if same type if $strict), else false. array_pop - array_pop() pops and returns the last value of the array , shortening the array by one element. If array is empty (or is not an array), NULL will be returned. Bueno?
I already know those, but many find it handy to view them in examples like <?php $arr = array(1,2,3,4,5); $noArr = ""; echo (is_array($arr)) ? '$arr is an array' : '$arr is NO array'; echo (is_array($noArr)) ? '$noArr is an array' : '$noArr is NO array'; ?> PHP: in_array: <?php $arr = array(1 => "key1", 2 => "Key 2", 3 => "Key 3"); echo (in_array("Key 1", $arr)) ? 'Found' : 'Not found'; echo (in_array("Key 0", $arr)) ? 'Found' : 'Not found'; ?> PHP: etc etc
Exactly what I was about to say. I bet these tutorials are from php.net anyways. You really don't need anything besides a portable webserver and php.net to learn.