<?php
function array_display($array, $pre=FALSE)
{
$tag = $pre ? 'pre' : 'p';
printf("<%s>%s%s>\n", $tag, var_export($array, TRUE), $tag);
}
$arr1 = array(1, 2, 3);
$arr2 = array(10, 20, 30);
$arr3 = array(5, 10, 15, 20);
$comb1 = array_merge($arr1, $arr2);
$comb2 = array_merge($arr2, $arr1);
$comb3 = array_merge($arr3, $arr2, $arr1);
array_display($comb1);
array_display($comb2);
array_display($comb3);
$arr4 = array("a", "b", "c", "d");
$arr5 = array(7, 8, 9, 10);
echo "<hr>";
$comb4 = array_merge($arr4, $arr5);
array_display($comb4);
?>
Here is the next tutorial:
<?php
function array_eq_ident($arr1, $arr2)
{
printf("
The two arrays are %sequal.
\n", $arr1 == $arr2 ? '' : "not ");printf("
The two are arrays are %sidentical.
\n", $arr1 === $arr2 ? '' : "not ");}
$dogs = array('Lassie' => 'Collie', 'Bud' => 'Sheepdog', 'Rin-Tin-Tin' => 'Alsatian', 'Snoopy' => 'Beagle');
$pups = array('Lassie' => 'Collie', 'Bud' => 'Sheepdog', 'Rin-Tin-Tin' => 'Alsatian', 'Snoopy' => 'Beagle');
$mutts = array('Lassie' => 'Collie', 'Rin-Tin-Tin' => 'Alsatian', 'Bud' => 'Sheepdog', 'Snoopy' => 'Beagle');
print "
\$dogs and \$pups:
\n";array_eq_ident($dogs, $pups);
print "
\$dogs and \$mutts:
\n";array_eq_ident($dogs, $mutts);
?>
No comments:
Post a Comment