-
personal web page
PHP array_diff_ukey() Function
<?php
function myfunction($v1,$v2)
{
if ($v1===$v2)
{
return 0;
}
if ($v1>$v2)
{
return 1;
}
else
{
return -1;
}
}
$a1=array(0=>"Dog",1=>"Cat",2=>"Horse");
$a2=array(3=>"Rat",1=>"Bird",5=>"Monkey");
print_r(array_diff_ukey($a1,$a2,"myfunction"));
?>
-
personal web page
PHP array_change_key_case() Function
Example 1
<?php
$a=array("a"=>"Cat","b"=>"Dog","c"=>"Horse");
print_r(array_change_key_case($a,CASE_UPPER));
?>
Example 2
<?php
$a=array("a"=>"Cat","b"=>"Dog","c"=>"Horse","B"=>" Bird");
print_r(array_change_key_case($a,CASE_UPPER));
?>
-
personal web page
PHP array_chunk() Function
<?php
$a=array("a"=>"Cat","b"=>"Dog","c"=>"Horse","d"=>" Cow");
print_r(array_chunk($a,2));
?>
Array (
[0] => Array ( [0] => Cat [1] => Dog )
[1] => Array ( [0] => Horse [1] => Cow )
)
Example 2
<?php
$a=array("a"=>"Cat","b"=>"Dog","c"=>"Horse","d"=>" Cow");
print_r(array_chunk($a,2,true));
?>
-
personal web page
PHP array_combine() Function
Example 1
<?php
$a1=array("a","b","c","d");
$a2=array("Cat","Dog","Horse","Cow");
print_r(array_combine($a1,$a2));
?>
Example 2
The output of the code above will be:
Array ( [a] => Cat [b] => Dog [c] => Horse [d] => Cow )
-
personal web page
PHP array_pop() Function
<?php
$a=array("Dog","Cat","Horse");
array_pop($a);
print_r($a);
?>
The output of the code above will be:
Array ( [0] => Dog [1] => Cat )
-
personal web page
PHP array_slice() Function
Example 1
<?php
$a=array(0=>"Dog",1=>"Cat",2=>"Horse",3=>"Bird");
print_r(array_slice($a,1,2));
?>
Example 2
<?php
$a=array(0=>"Dog",1=>"Cat",2=>"Horse",3=>"Bird");
print_r(array_slice($a,-2,1));
?>
-
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