Wednesday, June 18, 2008

PHP Array Functions

Array Merge

$array1 = array("fruits" => "apple", 2, 4);
$array2 = array("a", "b", "fruits" => "orange", "shape" => "rectangle", 4);
$result = array_merge($array1, $array2);
print_r($result);

Array Combine

$a = array('a', 'b', 'c');
$b = array('d', 'e', 'f');
$c = array_combine($a, $b);
print_r($c);

Array Push

$stack = array("a", "b");
array_push($stack, "c", "d");
print_r($stack);

Array Pop

$stack = array("a", "b", "c", "d");
$fruit = array_pop($stack);
print_r($stack);

1 comment:

Anonymous said...

Hi

I read this post two times.

I like it so much, please try to keep posting.

Let me introduce other material that may be good for our community.

Source: Medical assistant interview questions

Best regards
Henry