Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function for_Each($array){ //Creates function for_Each that takes $array as param.
- if ( count($array) === 0 ) //Error if $array is empty.
- {
- throw new Exception('MOM, this one is empty already!',2);
- }
- for ( $i = 0; $i < count($array); $i++ ) //Loop 'for' created to go through $array with $i while $i < count($array).
- {
- echo $i . ':' . $array[$i] . PHP_EOL; //Displays $i (the array's index), then ':', then $array[$i] (the value corresponding to the index of $array)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement