Example
<?php
echo “<pre>”;
$array = array(‘PHP’,’ ASP’, ‘JS’,’AS’);
arsort($array);
print_r($array);
?>
Output
Array
(
[0] => PHP
[2] => JS
[3] => AS
[1] => ASP
)
Example
<?php
echo “<pre>”;
$array = array(‘PHP’,’ ASP’, ‘JS’,’AS’);
arsort($array);
print_r($array);
?>
Output
Array
(
[0] => PHP
[2] => JS
[3] => AS
[1] => ASP
)
Example
<?php
echo “<pre>”;
$array = array(‘PHP’,’ ASP’, ‘JS’,’AS’);
print_r($array);
?>
Output
Array
(
[0] => PHP
[1] => ASP
[2] => JS
[3] => AS
)
Example
<?php
function func($value,$key){
echo “The key $key has the value $value<br />”;
}
$arr1=array(“p”=>”php”,”a”=>”ASP”);
array_walk($arr1,”func”);
?>
Output
The key p has the value php
The key a has the value ASP
Example
<?php
function func($value,$key){
echo “The key $key has the value $value<br />”;
}
$arr1=array(“p”=>”php”,”a”=>”ASP”);
$arr2=array($arr1,”1″=>”JS”,”2″=>”VS”);
array_walk_recursive($arr2,”func”);
?>
Output
The key p has the value php
The key a has the value ASP
The key 1 has the value JS
The key 2 has the value VS
Example
<?php
echo “<pre>”;
$array = array(“PHP”, “ASP”);
print_r(array_values($array));
?>
Output
Array
(
[0] => PHP
[1] => ASP
)
Example
<?php
echo “<pre>”;
$array = array(“PHP”, “ASP”);
($array, “JS”, “AS”);
print_r($array);
?>
Output
Array
(
[0] => JS
[1] => AS
[2] => PHP
[3] => ASP
)
<?php
echo “<pre>”;
$array1 = array(“a” => “PHP”, “PHP”, “b” => “ASP”, “ASP”, “JSP”);
print_r(array_unique($array1));
?>
Output
Array
(
[a] => PHP
[b] => ASP
[2] => JSP
)
Example
<?php
echo “<pre>”;
$array1 = array(“a” => “php”, “b” => “asp”, “c” => “AS”, “JS”);
$array2 = array(“a” => “PHP”, “B” => “asp”, “AS”, “JS”);
print_r(array_uintersect($array1, $array2, “strcasecmp”));
?>
Output
Array
(
[a] => php
[b] => asp
[c] => AS
[0] => JS
)
Example
<?php
echo “<pre>”;
$array1 = array(“a” => “php”, “b” => “asp”, “c” => “AS”, “JS”);
$array2 = array(“a” => “PHP”, “B” => “asp”, “AS”, “JS”);
print_r(array_uintersect_uassoc($array1, $array2, “strcasecmp”, “strcasecmp”));
?>
Output
Array
(
[a] => php
[b] => asp
)
Example
<?php
function func1($arg1,$arg2)
{
if ($arg1===$arg2)
{
return 0;
}
return 1;
}
echo “<pre>”;
$array1=array(“a”=>”PHP”,”b”=>”JSP”,”c”=>”AS”);
$array2=array(a=>”PHP”,b=>”ASP”,c=>”JS”);
print_r(array_uintersect_assoc($array1,$array2,”func1″));
?>
Output
Array
(
[a] => PHP
)