I was wondering how you could unshift a key value pair onto an array.
In the manual one suggested using a function like this:
function array_unshift_assoc(&$arr, $key, $val)
    $arr = array_reverse($arr, true);
    $arr[$key] = $val;
    $arr = array_reverse($arr, true);
    return count($arr);
it is a nice trick but this did not really convince me.
When you have eg an array like this: $a = array("foo"=>"bar",
"foo2"=>"bar2") and you do an array_shift operation,
you end up with ("foo2"=>"bar2"). So it is really easy to *remove* a
pair, but how do you put one in ?

PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to