Simple Example of PHP Array Function Predefined functions: 1: sizeof(): This function returns the number of elements in an array. Eg: $data = array("red", "green", "blue"); echo "Array has " . sizeof($data) . " elements"; Output: Array has 3 elements 2: array_values($arr): This function accepts a PHP array and returns a new array containing only its values (not its keys). Eg :$data = array("hero" => "Holmes", "villain" => "Moriarty"); print_r(array_values($data)); Output: Array ( [0] => Holmes,[1] => Moriarty) 3: array_pop($arr): This function removes an element from the end of an array. $data = array("Donald", "Jim", "Tom"); array_pop($data); print_r($data); ?> Output: Array( [0] => Donald [1] => Jim ) 4: array_push($arr, $val): This function adds an element to the end of an array. $data = array("Don...
Coding Cheatsheets - Learn web development code and tutorials for Software developers which will helps you in project. Get help on JavaScript, PHP, XML, and more.