<?php
$list=array("monday","tuesday","wednesday","Thursday");
echo $list[0];
echo "<hr>";
$list=array("monday"=>1,"tuesday"=>2,"Thursday"=>3);
echo $list['monday'];
echo "<hr>";
$list=array(2,4,6,8);
unset($list[2]);
echo $list[3];
echo "<hr>";
$cities=array("Hoboken","Chicago","Moab","Atlantis");
$city=current($cities);
echo "The first city is ".$city;
echo "<hr>";
while($city=next($cities)){
echo $city."<br>";
}
echo "<hr>";
$last=end($cities);
echo $last;
echo "<hr>";
foreach($cities as $temp){
echo $temp."<br>";
}
echo "<hr>";
foreach($cities as $key=>$value){
echo $key."th city is ".$value."<br>";
}
echo "<hr>";
echo "<h3>Sorting</h3>";
$original=array("Fred"=>31,"Al"=>27,"Gandalf"=>"Wizard","Betty"=>42,"Frodo"=>"hobbit");
echo "<h4>Original Array</h4>";
foreach($original as $key=>$value){
echo $key."=>".$value."<br>";
}
echo "<h4>Array ASort</h4>";
$new=$original;
asort($new);
foreach($new as $key=>$value){
echo $key."=>".$value."<br>";
}
echo "<h4>Array Sort</h4>";
$new=$original;
sort($new);
foreach($new as $key=>$value){
echo $key."=>".$value."<br>";
}
echo "<h4>Array KSort</h4>";
$new=$original;
ksort($new);
foreach($new as $key=>$value){
echo $key."=>".$value."<br>";
}
?>
$list=array("monday","tuesday","wednesday","Thursday");
echo $list[0];
echo "<hr>";
$list=array("monday"=>1,"tuesday"=>2,"Thursday"=>3);
echo $list['monday'];
echo "<hr>";
$list=array(2,4,6,8);
unset($list[2]);
echo $list[3];
echo "<hr>";
$cities=array("Hoboken","Chicago","Moab","Atlantis");
$city=current($cities);
echo "The first city is ".$city;
echo "<hr>";
while($city=next($cities)){
echo $city."<br>";
}
echo "<hr>";
$last=end($cities);
echo $last;
echo "<hr>";
foreach($cities as $temp){
echo $temp."<br>";
}
echo "<hr>";
foreach($cities as $key=>$value){
echo $key."th city is ".$value."<br>";
}
echo "<hr>";
echo "<h3>Sorting</h3>";
$original=array("Fred"=>31,"Al"=>27,"Gandalf"=>"Wizard","Betty"=>42,"Frodo"=>"hobbit");
echo "<h4>Original Array</h4>";
foreach($original as $key=>$value){
echo $key."=>".$value."<br>";
}
echo "<h4>Array ASort</h4>";
$new=$original;
asort($new);
foreach($new as $key=>$value){
echo $key."=>".$value."<br>";
}
echo "<h4>Array Sort</h4>";
$new=$original;
sort($new);
foreach($new as $key=>$value){
echo $key."=>".$value."<br>";
}
echo "<h4>Array KSort</h4>";
$new=$original;
ksort($new);
foreach($new as $key=>$value){
echo $key."=>".$value."<br>";
}
?>