Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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
 
 
Register now for full access!
Old 08-03-2004, 04:49 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
Use unset() to delete one element.

PHP Code:
unset($multi[0]); // no more $row_0 in $multi 
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
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

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
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().
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
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.59309 seconds with 12 queries