-
personal web page
PHP array_reverse() Function
<?php
$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse");
print_r(array_reverse($a));
?>
Array ( [c] => Horse [b] => Cat [a] => Dog )
-
personal web page
PHP array_uintersect() Function
<?php
function myfunction($v1,$v2)
{
if ($v1===$v2)
{
return 0;
}
if ($v1 > $v2) return 1;
{
return -1;
}
return 1;
}
$a1=array("a"=>"Cat","b"=>"Dog","c"=>"Horse");
$a2=array(1=>"Cat",2=>"Dog",3=>"Fish");
print_r(array_uintersect($a1,$a2,"myfunction"));
?>
-
personal web page
PHP array_walk_recursive() Function
<?php
function myfunction($value,$key)
{
echo "The key $key has the value $value<br />";
}
$a1=array("a"=>"Cat","b"=>"Dog");
$a2=array($a1,"1"=>"Bird","2"=>"Horse");
array_walk_recursive($a2,"myfunction");
?>
-
personal web page
PHP key() Function
<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");
echo "The key from the current position is: " . key($people);
?>
-
personal web page
PHP shuffle() Function
<?php
$my_array = array("a" => "Dog", "b" => "Cat", "c" => "Horse");
shuffle($my_array);
print_r($my_array);
?>
-
personal web page
PHP uksort() Function
<?php
function my_sort($a, $b)
{
if ($a == $b) return 0;
return ($a > $b) ? -1 : 1;
}
$people = array("Swanson" => "Joe",
"Griffin" => "Peter", "Quagmire" => "Glenn",
"swanson" => "joe", "griffin" => "peter",
"quagmire" => "glenn");
uksort($people, "my_sort");
print_r ($people);
?>
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks