FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » for each syntax
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
for each syntax [message #169597] Sat, 18 September 2010 20:02 Go to previous message
GarryJones is currently offline  GarryJones
Messages: 21
Registered: September 2010
Karma:
Junior Member
I need to automatically write a few lines of code with php.

This is the output i need
if ($_POST['resmalval109'] == 109) {
$resmalval=109;
} elseif ($_POST['resmalval110'] == 110) {
$resmalval=110;
} elseif ($_POST['resmalval111'] == 111) {
$resmalval=111;
} elseif ($_POST['resmalval112'] == 112) {
$resmalval=112;
} elseif ($_POST['resmalval113'] == 113) {
$resmalval=113;
} elseif ($_POST['resmalval114'] == 114) {
$resmalval=114;
} elseif ($_POST['resmalval115'] == 115) {
$resmalval=115;
} else {
// something else
}

The required numbers just happen to be sequential at the moment, but
over time these values will change, Instead of manually writing the
above code every time I want to create it with php.

I have the required numbers in an array.
$arr_single = array(109,110,111,112,113,114,115);

So my guess is using "for each" I can write in each number where it is
needed until the array is empty. I can't use the $var++ trick as these
numbers can (for example) change to

$arr_single = array(109,111,112,113,115);

Any help in right direction greatly appreciated.,,
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: Illegal variable _files
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 21:02:46 GMT 2024

Total time taken to generate the page: 0.04077 seconds