Write a PHP script to get the last value of an array without affecting the pointer
<?php $colors = array('c1' => 'Red', 'c2' => 'Green', 'c3' => 'White', 'c4' => 'Black'); echo next($colors)."\n"; $last = array_pop(array_keys(array_flip($colors))); echo $last."\n"; echo current($colors)."\n"; ?>
Sample Output:
Green Black Green
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer