Roy Barten Posted February 18, 2009 Share Posted February 18, 2009 I created an array with some data in it. Is it possible to create an array and to fill in the data later? For example: First i want to fill in a start and enddate into the array and later i want to fill in an id into this array Is this possible? and how do i do this? Link to comment https://forums.phpfreaks.com/topic/145734-solved-insert-data-into-an-array/ Share on other sites More sharing options...
peddel Posted February 18, 2009 Share Posted February 18, 2009 just add NULL on the position u dont need, and replace it when the time is right. For example : U want finally name age sex U first make array $person = array('Steven',NULL,'male'); Then when the time is right u add the age $person[1] = '24'; (2nd position) Link to comment https://forums.phpfreaks.com/topic/145734-solved-insert-data-into-an-array/#findComment-765143 Share on other sites More sharing options...
Cal Posted February 18, 2009 Share Posted February 18, 2009 I think you might want to use array_push() Example <?php $array = array("start", "end"); array_push($array, "id"); ?> Then use print_r and it should come up with start, end and id. Link to comment https://forums.phpfreaks.com/topic/145734-solved-insert-data-into-an-array/#findComment-765144 Share on other sites More sharing options...
kenrbnsn Posted February 18, 2009 Share Posted February 18, 2009 You can also just add it, no function required: <?php $test = array($start,$end); $test[] = $id; ?> or <?php $test1 = array('start' => $start, 'end'=>$end); $test1['id'] = $id; ?> Ken Link to comment https://forums.phpfreaks.com/topic/145734-solved-insert-data-into-an-array/#findComment-765148 Share on other sites More sharing options...
Roy Barten Posted February 18, 2009 Author Share Posted February 18, 2009 Okey thanks!!! Link to comment https://forums.phpfreaks.com/topic/145734-solved-insert-data-into-an-array/#findComment-765163 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.