Revision: 20708
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 23, 2009 14:13 by chrisaiv
Initial Code
<?php $numbers = array( 1, 2, 3, 4, 5, 6 ); print_r( $numbers ); echo "<br /><br />"; //Remove the first element out of the array $a = array_shift( $numbers ); echo "a: " . $a . "<br />"; print_r( $numbers ); echo "<br /><br />"; //Re-insert an element to the beginning of an array $b = array_unshift( $numbers, 'first' ); echo "b: " . $b . "<br />"; print_r( $numbers ); echo "<br /><br />"; //Remove the last element from an array $c = array_pop( $numbers ); echo "c: " . $c . "<br />"; print_r( $numbers ); echo "<br /><br />"; //Re-insert an element to the end of an array $d = array_push( $numbers, 'last' ); echo "d: " . $d . "<br />"; print_r( $numbers ); echo "<br /><br />"; //How many items are in the array echo "Count: " . count( $numbers ) . "<br /><br />"; //Maximum Value echo "Max Value: " . max( $numbers ) . "<br /><br />"; //Minimum Value echo "Min Value: " . min( $numbers ) . "<br /><br />"; //Sort from lowest to higest echo "Sort: " . sort( $numbers ); echo print_r($numbers) . "<br />"; //Sort from highest to lowest echo "Reverse Sort: " . rsort( $numbers ); print_r($numbers) . "<br /><br />"; echo "<br /><br />"; $implode = implode( " * ", $numbers ); echo "Implode: " . $implode . "<br /><br />"; //Take the String, find the delimiter, then turn it into an array echo "Explode: " . print_r( explode( " * ", $implode ) ) . "<br /><br />"; ?>
Initial URL
Initial Description
Initial Title
PHP: Fun with Arrays
Initial Tags
php
Initial Language
PHP