![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| I'm sure there must be a simple way to do this, but it's eluding me! I have a number of variables coming from a form e.g. $place_text $place_combo $town_text $town_combo $type_text $town_combo etc.... I have a loop that loops through the array: $formarray = array("place", "town", "type"); foreach ($formarray as $thiselement) { // Here I'd like to be able to use the value of $thiselement // to get at the value of each of the form variables // $place_text, $place_combo, $town_text, $town_combo etc. // If this were Perl, I'd do ${thiselement}_text and // ${thiselement}_combo but it doesn't work in PHP. } Interestingly, if the aforementioned Perl solution is in quotes as an echo i.e. echo "${thiselement}_text"; it works, but not in the syntax I'm using it in: if ( (${"thisfield"}_combo == -1) && (empty(${"thisfield"}_text)) ) { Can anyone suggest a solution to this please? | |||
| | #2 | ||
| "MrBoom" <andy_isherwood@hotmail.com> wrote in message news:9b6a13b2.0308010213.30b0fe49@posting.google.c om... > Interestingly, if the aforementioned Perl solution is in quotes as an > echo i.e. echo "${thiselement}_text"; it works, but not in the syntax > I'm using it in: > > if ( (${"thisfield"}_combo == -1) && (empty(${"thisfield"}_text)) ) { > > Can anyone suggest a solution to this please? if ( (${$thisfield."_combo"} == -1) && (empty(${$thisfield."_text"})) ) { JW | |||
| Featured Websites | ||||
|
![]() |
| Tags: loop, name, part, using, variable |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Session variable reading doesn't work | Peter | PHP | 7 | 07-01-2007 3:57 PM |
| set session variable with <a href>- how? | Anthony M. Saffer | PHP | 0 | 07-01-2007 3:47 PM |
| Session variable seems not work | Simon | PHP | 0 | 07-01-2007 3:33 PM |
| regex for PHP variable name | Sebosac | PHP | 2 | 05-20-2007 6:34 PM |
| regex for PHP variable name | Sebosac | PHP | 0 | 05-20-2007 6:34 PM |
| Featured Websites | ||||
|