ptmuldoon
01-21-2008, 04:45 PM
I'm trying to add another value to an existing array using array_push. But when I do so, the key is being assigned as '0', when I would like to give it a name.
Is array push the best method to use, or is there a another/simpler way?
Here's the code:
while ($row = mysql_fetch_assoc($rs_result)) {
$add_item = 'Net Item';
array_push($row,$add_item);
echo '<pre>';
print_r($row);
echo '</pre>';
?>
And the output is
Array
(
[gid] => 1163
[capacity] => 8
[speed] => 2
[0] => Net Item
)
Is array push the best method to use, or is there a another/simpler way?
Here's the code:
while ($row = mysql_fetch_assoc($rs_result)) {
$add_item = 'Net Item';
array_push($row,$add_item);
echo '<pre>';
print_r($row);
echo '</pre>';
?>
And the output is
Array
(
[gid] => 1163
[capacity] => 8
[speed] => 2
[0] => Net Item
)