$numbers = array(1,2,3,4,5,6);
print_r($numbers);
echo "
";
// shifts first element out of an array
// and returns it.
$a = array_shift($numbers);
echo "a:" . $a ."
";
print_r($numbers);
echo "
";
// prepends an element to an array,
// returns the element count.
$b = array_unshift($numbers, 'first');
echo "b: ". $b ."
";
print_r($numbers);
echo "
";
echo "
";
// pops last element out of an array
// and returns it.
$a = array_pop($numbers);
echo "a: " . $a ."
";
print_r($numbers);
echo "
";
// pushes an element onto the end of an array,
// returns the element count.
$b = array_push($numbers, 'last');
echo "b: ". $b ."
";
print_r($numbers);
echo "
";
No comments:
Post a Comment