Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

   

Reply
 
LinkBack Thread Tools Display Modes
Old 02-28-2007, 04:16 PM   #1 (permalink)
Contributing Member
 
bytech's Avatar
 
Join Date: 10-13-03
Location: Manitoba, Canada
Posts: 573
iTrader: 0 / 0%
Latest Blog:
None

bytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nice
Send a message via Skype™ to bytech
PHP Appending to MultiDimensional Arrays

Ack, the title of this post is a mouth full! Anyway, what does everyone recommend for appending new arrays to a multidimensional (3D) array in PHP? Best command or sample code should answer my question nicely.
__________________
Canada based Web Design Forums. Join us in the fun today!
bytech is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-01-2007, 10:05 PM   #2 (permalink)
Inactive
 
littleFella's Avatar
 
Join Date: 06-20-04
Location: Ontario
Posts: 3,359
iTrader: 0 / 0%
Latest Blog:
None

littleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to behold
I don't think in PHP you can even do dynamic arrays that are more than only linear (single dimension).
You may have some success if you use a database table or two instead since database table data is dynamic (of course).
littleFella is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-02-2007, 02:46 PM   #3 (permalink)
Contributing Member
 
bytech's Avatar
 
Join Date: 10-13-03
Location: Manitoba, Canada
Posts: 573
iTrader: 0 / 0%
Latest Blog:
None

bytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nice
Send a message via Skype™ to bytech
PHP definitely has 3D / Multidimensional arrays, and I can create them easily enough. I just wanted an easy to perform append. I could read back the 3D array from the DB, add my new one, and then write back, but that is a bit clunky. I'm looking for something like array_merge (but that one overwrites keys if they are named the same)...

I'd much prefer to use a new table and add records, 1 per entry... but I am working within a very bib and popular system, and that is also a secondary option (adding new tables). I may have to do one of the things I'm trying to avoid (read full array, add, write back / add another table), but only as a last resort.
__________________
Canada based Web Design Forums. Join us in the fun today!
bytech is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-02-2007, 09:11 PM   #4 (permalink)
Inactive
 
littleFella's Avatar
 
Join Date: 06-20-04
Location: Ontario
Posts: 3,359
iTrader: 0 / 0%
Latest Blog:
None

littleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to behold
Quote:
Originally Posted by bytech View Post
PHP definitely has 3D / Multidimensional arrays, and I can create them easily enough. I just wanted an easy to perform append.
I never said PHP didn't allow for 3D arrays. I said 3D arrays in PHP can't be dynamic. Only !D arrays can be dynamic in PHP. Unless "append" is something that we both understand in different ways in regards to arrays.
littleFella is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-03-2007, 06:03 AM   #5 (permalink)
Inactive
 
Join Date: 01-23-07
Location: Netherworld, under Buenos Aires.
Posts: 169
iTrader: 0 / 0%
Hades is liked by somebodyHades is liked by somebodyHades is liked by somebodyHades is liked by somebody
Send a message via MSN to Hades Send a message via Yahoo to Hades
Maybe this user contribution to the php.net community can be helpful:

http://ar.php.net/manual/en/function...erge.php#68247

That user posted something interesting, but I don't know if that is what you need.
Hades is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-03-2007, 07:06 PM   #6 (permalink)
Contributing Member
 
bytech's Avatar
 
Join Date: 10-13-03
Location: Manitoba, Canada
Posts: 573
iTrader: 0 / 0%
Latest Blog:
None

bytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nicebytech is just really nice
Send a message via Skype™ to bytech
Thanks for your help everyone. I found the answer, and I feel pretty silly:
Adding to 3D arrays is as easy as adding to regular arrays!

$users[] = $newuser;

That's bloody it! Amazing, huh? If $users is a 3D array, and $newuser is an array, it just adds it to the 3D array like I need it to. When all else fails, try the simplest thing you can think of! Oh well, the 5-6 hours I spent researching this answered some questions I'll need to take care of later, and I learned a ton while at it.
__________________
Canada based Web Design Forums. Join us in the fun today!
bytech is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with PHP and arrays I think Arenlor Coding Forum 4 01-19-2007 11:35 AM
Appending to logged PHP error messages thing2b Coding Forum 2 10-09-2006 12:26 PM
PHP - Using assoc. arrays in SQL string trevHCS Coding Forum 1 09-24-2004 03:49 AM


Sponsor Links
Webmaster Forum Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 02:53 AM.
© Copyright 2008 V7 Inc