Talk:Associative array/Creation: Difference between revisions
Content added Content deleted
No edit summary |
(→PHP) |
||
Line 10: | Line 10: | ||
== PHP == |
== PHP == |
||
I don't know if it is relevant, but should we add user-made functions ? I know I often use a hand made function because it's really convenient... Anyway, here is the PHP Manual version, dunno if it should be added: |
I don't know if it is relevant, but should we add user-made functions ? I know I often use a hand made function because it's really convenient... Anyway, here is the PHP Manual version, dunno if it should be added: |
||
<? |
<? |
||
// Append associative array elements |
// Append associative array elements |
||
function array_push_associative(&$arr) { |
function array_push_associative(&$arr) { |
||
$args = func_get_args(); |
$args = func_get_args(); |
||
foreach ($args as $arg) { |
foreach ($args as $arg) { |
||
Line 25: | Line 26: | ||
} |
} |
||
return $ret; |
return $ret; |
||
} |
} |
||
It's like [[http://fr2.php.net/array_push array_push ()]], up to the part that it actually allows associative elements to be added (pushed)... More info: http://fr2.php.net/manual/en/function.array-push.php#58705 |
It's like [[http://fr2.php.net/array_push array_push ()]], up to the part that it actually allows associative elements to be added (pushed)... More info: http://fr2.php.net/manual/en/function.array-push.php#58705 |