note 22112 modified in function.array-splice by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 14:50:00 +0000 |
| Subject: | note 22112 modified in function.array-splice by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-80011@lists.php.net to get a copy of this message | ||
After reading KoKos' post above, I thought that the code I posted right before his should do
what he wanted. However, my original post neglected to note the little "Tip" in the
documentation above, about a single element replacement.
If one changes the lines in my code above that says:
<?php
if(is_array($replacement))
foreach($replacement as $r_key=>$r_value)
$new_array[$r_key]=$r_value;
?>
to instead say:
<?php
if(is_string($replacement))
$new_array[$key]=$replacement;
elseif(is_array($replacement))
foreach($replacement as $r_key=>$r_value)
$new_array[$r_key]=$r_value;
?>
that will solve the problem.
Sorry for the omission.
--was--
After reading KoKos' post above, I thought that the code I posted right before his should do
what he wanted. However, my original post neglected to note the little "Tip" in the
documentation above, about a single element replacement.
If one changes the lines in my code above that says:
if(is_array($replacement))
foreach($replacement as $r_key=>$r_value)
$new_array[$r_key]=$r_value;
to instead say:
if(is_string($replacement))
$new_array[$key]=$replacement;
elseif(is_array($replacement))
foreach($replacement as $r_key=>$r_value)
$new_array[$r_key]=$r_value;
that will solve the problem.
Sorry for the omission.
http://php.net/manual/en/function.array-splice.php