is there any array replace function in php ..
in php manual there is a function called array_replace but its not working...
Tell me some example...
for array replace..
is there any array replace function in php ..
in php manual there is a function called array_replace but its not working...
Tell me some example...
for array replace..
<?php
$base = array("orange", "banana", "apple", "raspberry");
$replacements = array(0 => "pineapple", 4 => "cherry");
$replacements2 = array(0 => "grape");
$basket = array_replace($base, $replacements, $replacements2);
print_r($basket);
?>
below one is working fine.
$arr2 = array('id' => 12, 'login' => 'john.doe', 'credit' => 100); print_r($arr2); $arr2['id']='bharani'; print_r($arr2);
<?php
$base = array("orange", "banana", "apple", "raspberry");
$replacements = array(0 => "pineapple", 4 => "cherry");
$replacements2 = array(0 => "grape");
$basket = array_replace($base, $replacements, $replacements2);
echo '<pre>' .
print_r($base, true) .
print_r($basket, true) .
'</pre>';
output
Array
(
[0] => orange
[1] => banana
[2] => apple
[3] => raspberry
)
Array
(
[0] => grape
[1] => banana
[2] => apple
[3] => raspberry
[4] => cherry
)
the question is: what exactly isnt working for you?