The array_map function in PHP loops over each elements of the passed array(s), and runs the given function. It then returns a new array that contains the values returned by each call to the given function.
Chat with our AI personalities
the dollar sign appears before a variable/array. Essentially it just tells php that its a variable. $food = "cheese pizza"; or $myfavoritenumber = 2 ;
In the declaration of the receiving function, you add an ampersand. <?php function myWayCoolFunction( &$params) {.....} $x = array('1','2','3'); myWayCoolFunction($x) ?>
To merge arrays in PHP all you have to do is use the array_merge() function like shown below: <?php $array1 = array("Matt", "Michael", "Justin"); $array2 = array("Janice", "Janet", "Kylie"); $array3 = array_merge($array1, $array2); ?> One thing to remember when merging arrays is you might be creating duplicate results, if you don't want 2 or more of the same result in the array remember to use the function array_unique() to remove the duplicate results from it!
A key is the name of a variable in an array ($array["key"]) and the index is the position it's at ($array = ["key" => 0], the index would be 0). Keys and indices are the same if the array is not associative though ($array = [true], the key holding the value true is named 0 and is at index 0).
The $_POST array contains only variables supplied by a form that used the POST method, while the $_REQUEST array combines the $_POST, $_GET and $COOKIE arrays.