[PHP] filling an array(2)
h. Ok. Can somebody explain this one? Why won't it work correctly? for($m=1;$m=5;$m++){ $div_idd[$m]=${'row-sub' . $m . 'd'}; } Can it not be done with a 3 parter? The columns in the table that $row gets, are sub1d, sub2d, sub3d, sub4d and sub5d. Or is it the - that is messing it up? I have tried escaping them row\-\sub, but that didn't work. What would I search for on the PHP site or where are directions located that tells me how to use this type of putting a variable together. It makes it hard to search for it if I don't know what it is called. Thanks Steve -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] filling an array
Thank You Andrey, Matt and Martin for your answers. To summarize for everyone, here are the answers: From Andrey (tested, works): for($m=1;$m=5;$m++){ $div_id[$m]=${'divid'.$m}; } From Matt: for($m=1;$m=5;$m++){ $varName = 'divId' . $m; $div_id[$m]=${$varName} } From Martin: for($i =0; $i 5; $i++) { $offset = $m + 1; $divid[$m] = $div_id{$offset}; } At 10:55 PM 7/26/2002 +0300, you wrote: - Original Message - From: Steve Buehler [EMAIL PROTECTED] To: PHP [EMAIL PROTECTED] Sent: Friday, July 26, 2002 10:48 PM Subject: [PHP] filling an array Can anyone tell me what I am doing wrong? I am essentially trying to do this: $divid[1] = $div_id1; $divid[2] = $div_id2; $divid[3] = $div_id3; $divid[4] = $div_id4; $divid[5] = $div_id5; But I was looking for a tighter way, like the following (which does not work): for($m=1;$m=5;$m++){ $div_id[$m]=$divid$m; } Can anybody tell me how to do this in a for statement? Thanks In Advance Steve -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3 -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] filling an array
for($m=1;$m=5;$m++){ $div_id[$m]=${'divid'.$m}; } Regards, Andrey - Original Message - From: Steve Buehler [EMAIL PROTECTED] To: PHP [EMAIL PROTECTED] Sent: Friday, July 26, 2002 10:48 PM Subject: [PHP] filling an array Can anyone tell me what I am doing wrong? I am essentially trying to do this: $divid[1] = $div_id1; $divid[2] = $div_id2; $divid[3] = $div_id3; $divid[4] = $div_id4; $divid[5] = $div_id5; But I was looking for a tighter way, like the following (which does not work): for($m=1;$m=5;$m++){ $div_id[$m]=$divid$m; } Can anybody tell me how to do this in a for statement? Thanks In Advance Steve -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] filling an array(2)
Ok. That makes since. Thanks Steve At 04:20 PM 7/26/2002 -0500, you wrote: var names can only be letters, numbers, and underscores. Jim Grill Support Web-1 Hosting http://www.web-1hosting.net - Original Message - From: Steve Buehler [EMAIL PROTECTED] To: PHP [EMAIL PROTECTED] Sent: Friday, July 26, 2002 3:53 PM Subject: [PHP] filling an array(2) h. Ok. Can somebody explain this one? Why won't it work correctly? for($m=1;$m=5;$m++){ $div_idd[$m]=${'row-sub' . $m . 'd'}; } Can it not be done with a 3 parter? The columns in the table that $row gets, are sub1d, sub2d, sub3d, sub4d and sub5d. Or is it the - that is messing it up? I have tried escaping them row\-\sub, but that didn't work. What would I search for on the PHP site or where are directions located that tells me how to use this type of putting a variable together. It makes it hard to search for it if I don't know what it is called. Thanks Steve -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3 -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] filling an array
Can anyone tell me what I am doing wrong? I am essentially trying to do this: $divid[1] = $div_id1; $divid[2] = $div_id2; $divid[3] = $div_id3; $divid[4] = $div_id4; $divid[5] = $div_id5; But I was looking for a tighter way, like the following (which does not work): for($m=1;$m=5;$m++){ $div_id[$m]=$divid$m; } Can anybody tell me how to do this in a for statement? Thanks In Advance Steve -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] filling an array(2)
for($m=1;$m=5;$m++){ $div_idd[$m]=${'row-sub' . $m . 'd'}; } I'm not sure if it will work, but you might try either using the mysql_fetch_array($result); function and then refer to them by $row[src1d]; or try $div_idd[$m] = $row-$$name; where $name = sub . $m . d; I'm not sure if that will work, but it might be worth a try. -- Steve Buehler [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Ok. That makes since. Thanks Steve At 04:20 PM 7/26/2002 -0500, you wrote: var names can only be letters, numbers, and underscores. Jim Grill Support Web-1 Hosting http://www.web-1hosting.net - Original Message - From: Steve Buehler [EMAIL PROTECTED] To: PHP [EMAIL PROTECTED] Sent: Friday, July 26, 2002 3:53 PM Subject: [PHP] filling an array(2) h. Ok. Can somebody explain this one? Why won't it work correctly? for($m=1;$m=5;$m++){ $div_idd[$m]=${'row-sub' . $m . 'd'}; } Can it not be done with a 3 parter? The columns in the table that $row gets, are sub1d, sub2d, sub3d, sub4d and sub5d. Or is it the - that is messing it up? I have tried escaping them row\-\sub, but that didn't work. What would I search for on the PHP site or where are directions located that tells me how to use this type of putting a variable together. It makes it hard to search for it if I don't know what it is called. Thanks Steve -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3 -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php