note 83212 modified in function.current by danbrown
| From: | danbrown@php.net | Date: | Fri, 10 Sep 2010 14:52:52 +0000 |
| Subject: | note 83212 modified in function.current by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-172443@lists.php.net to get a copy of this message | ||
A simple copy function that not only copies the given array but ensures the copy's pointer is
set to the exact same position:
<?php
function array_copy(&array)
{
$key = key($array);
$copy = $array;
while (($copy_key = key($copy)) !== NULL) {
if ($copy_key == $key) break;
next($copy);
}
return $copy;
}
?>
That's all ... bye.
--was--
A simple copy function that not only copies the given array but ensures the copy's pointer is
set to the exact same position:
function array_copy(&array)
{
$key = key($array);
$copy = $array;
while (($copy_key = key($copy)) !== NULL) {
if ($copy_key == $key) break;
next($copy);
}
return $copy;
}
That's all ... bye.
http://php.net/manual/en/function.current.php