Reply
Inserting an array - into an array of arrays
Old 08-03-2004, 04:46 PM Inserting an array - into an array of arrays
Average Talker

Posts: 15
Trades: 0
Hello - I've figured out how to delete an array from an array of arrays , but am having touble inserting an array into an array of array. (I know, tongue twister ...)

I've got:

$row_0 = array ("Row_A", " fooA", " fooA");
$row_1 = array ("Row_B", " fooB", " fooB");
$row_2 = array ("Row_C", " fooC", " fooC");
$row_3 = array ("Row_D", " fooD", " fooD");
$multi = array ($row_0, $row_1, $row_2, $row_3);

I'm pretty sure the following line of code wipes out the array named $row_1

array_splice ($multi, 1, 1 ); // starting at $multi[1] , take out 1 element


however ...


How do I get that array back into the multi array should I decide I want it back in its original position, or at any position for that matter?

I tried:

$new = $row_1;
array_splice ($multi, 1, 0, $new );

but no luck.
new_PHP_er is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 08-03-2004, 04:49 PM
Christopher's Avatar
Iced Cap

Posts: 3,113
Location: Toronto, Ontario
Trades: 0
Use unset() to delete one element.

PHP Code:
unset($multi[0]); // no more $row_0 in $multi 
Christopher is offline
Reply With Quote
View Public Profile Visit Christopher's homepage!
 
Old 08-03-2004, 06:22 PM
Average Talker

Posts: 15
Trades: 0
Thank you ... how do I insert the array ?
new_PHP_er is offline
Reply With Quote
View Public Profile
 
Old 08-03-2004, 06:37 PM
Christopher's Avatar
Iced Cap

Posts: 3,113
Location: Toronto, Ontario
Trades: 0
Oh sorry, I didn't see that part lol.

Could you not just add it to the end?
PHP Code:
$multi[] = $row_1
You can also look into array_merge().
Christopher is offline
Reply With Quote
View Public Profile Visit Christopher's homepage!
 
Reply     « Reply to Inserting an array - into an array of arrays
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.11678 seconds with 13 queries