<?php
$dogs = array('Lassie' => 'Collie', 'Bud' => 'Sheepdog', 'Rin-Tin-Tin' => 'German Shepherd', 'Snoopy' => 'Beagle');
printf("
%s\n", var_export($dogs, TRUE));
unset($dogs['Rin-Tin-Tin']);
printf("
%s\n", var_export($dogs, TRUE));
?>
Here is another tutorial dealing with arrays
<?php
$languages = array('French', 'German', 'Russian', 'Chinese', 'Hindi', 'Quecha');
printf("
Original array:
%s\n", var_export($languages, TRUE));
$removed = array_shift($languages);
printf("
Using array_shit():
Removed element: %s
%s\n", $removed, var_export($languages, TRUE));
$removed = array_pop($languages);
printf("
Using array_pop():
Removed element: %s
%s\n", $removed, var_export($languages, TRUE));
unset($languages[count($languages) - 1]);
printf("
Using unset() and count():
%s\n", var_export($languages, TRUE));
?>
No comments:
Post a Comment