Page 1 of 1

Adding to arrays, post creation... :P

Posted: Thu Apr 15, 2004 8:25 am
by imamember
Ok so I want to create an empty array...and then as things come up add them with a key. BUt now Arrays, dont have a "Add" method etc. Do I really have to now manually write a whole bunch of functions to do this?

Posted: Thu Apr 15, 2004 8:35 am
by AnsonM
hmmmmm.... i dont get it... could u rephrase?

Posted: Thu Apr 15, 2004 8:39 am
by magicrobotmonkey
http://us3.php.net/manual/en/language.t ... 6d421bab25

just go $mykeys[] = $newKey i think

Posted: Thu Apr 15, 2004 8:45 am
by vigge89

Code: Select all

<?php

$array = array();

// add to array
$array['id'] = 1;

?>

Posted: Thu Apr 15, 2004 8:55 am
by imamember
well sheesh isnt that simple...

Is it just me or do they not say that in the manual? THanks I was verging on using array_push() :P

Posted: Thu Apr 15, 2004 9:15 am
by magicrobotmonkey
look at the link I posted! It doesn't say it explicitly but you can deduce it from the discussion

Posted: Thu Apr 15, 2004 9:24 am
by imamember
lol, I didn't mean it isnt that simple I meant wow, thats very simple...thanks again, all sorted...