Adding to arrays, post creation... :P

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
imamember
Forum Newbie
Posts: 7
Joined: Thu Apr 15, 2004 7:00 am
Location: South Africa

Adding to arrays, post creation... :P

Post 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?
AnsonM
Forum Commoner
Posts: 72
Joined: Thu Sep 25, 2003 7:21 am

Post by AnsonM »

hmmmmm.... i dont get it... could u rephrase?
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

http://us3.php.net/manual/en/language.t ... 6d421bab25

just go $mykeys[] = $newKey i think
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

Code: Select all

<?php

$array = array();

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

?>
imamember
Forum Newbie
Posts: 7
Joined: Thu Apr 15, 2004 7:00 am
Location: South Africa

Post 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
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

look at the link I posted! It doesn't say it explicitly but you can deduce it from the discussion
imamember
Forum Newbie
Posts: 7
Joined: Thu Apr 15, 2004 7:00 am
Location: South Africa

Post by imamember »

lol, I didn't mean it isnt that simple I meant wow, thats very simple...thanks again, all sorted...
Post Reply