You are here: Re: sorting a multidimensional $_POST array « All PHP « IT news, forums, messages
Re: sorting a multidimensional $_POST array

Posted by Ed on 08/26/05 07:09

adam wrote:
> not sure if this is possible, ie:
>
> <input type="text" id="table1[username]">
> <input type="text" id="table1[password]">
> <input type="text" id="table2[bioText]">
>
> i'm assuming i could then get the value of the username with
>
> $username = $_POST[table1][username];
> etc...
>
> ideally what i'd like to do is loop through this multidimensional array
> with a function, so that each [table] key allows for posting different
> arrays of data to a different table (ie: table1 might be the user info,
> table2 might be extended profile data if they're updating their profile
> as well.. you get the idea).
>
> foreach() doesn't seem like it would work, unless something like
> $key[$key] is possible, but i doubt it :P


Hi there,

Perhaps someone else has a better solution, but have you tried a
foreach() loop inside a foreach() loop? For instance:

foreach ($_POST as $key => $value) {

if (is_array($value)) {

foreach ($value as $whatever) {
// do something
}
}
else {
// do something with $key and $value
}
}

Good luck,

Ed

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация