Paldo Posted May 27, 2009 Share Posted May 27, 2009 Hi guys! Could you please look at this if it could work somehow couse it's not working... Thanks <html> <body> <?php $NumberInStringFormat = $_POST[number]; echo $NumberInStringFormat; echo '<br>'; $lenght = strlen($NumberInStringFormat); echo $lenght; $IdetificatorArray = array( "1" => "ones" , "2" => "tens" , "3" => "hundreats" , "4" => "tousands" , "5" => "tentousands" , "6" => "houndrettousands" , "7" => "milions" , "8" => "tenmilions" , "9" => "houndretmilions" , "10" => "bilions" ); for ($i = $lenght ; $i = 0; $i-- ) { $valueArray = array( '$IdetificatorArray[$i]' => '(int)$NumberInStringFormat($i)' ); } print_r($valueArray); //1 364 720 434 ?> </body> </html> PS: What I was trying to do is get a array, for example if imput $numberInStringFormat is 345 the array should look like this: [hundreats] => 3; // all of these in int format... [tens] => 4; [ones] => 5; Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 27, 2009 Share Posted May 27, 2009 for ($i = $lenght ; $i = 0; $i-- ) { Your condition is wrong. Change $i = 0 to $i > -1. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted May 27, 2009 Share Posted May 27, 2009 $valueArray = array( '$IdetificatorArray[$i]' => '(int)$NumberInStringFormat($i)' ); should be $valueArray = array( $IdetificatorArray[$i] => $NumberInStringFormat{$i} ); Quote Link to comment Share on other sites More sharing options...
Paldo Posted May 27, 2009 Author Share Posted May 27, 2009 ok I change it to a form you can see above but now it say : Parse error: parse error, expecting `')'' in /3w/euweb.cz/p/parobek/zuzkeconfirm.php on line 29 what is actualy the line with the condition... Quote Link to comment Share on other sites More sharing options...
gevans Posted May 27, 2009 Share Posted May 27, 2009 show your new code Quote Link to comment Share on other sites More sharing options...
Paldo Posted May 27, 2009 Author Share Posted May 27, 2009 <html> <body> <?php $NumberInStringFormat = $_POST[number]; echo $NumberInStringFormat; echo '<br>'; $lenght = strlen($NumberInStringFormat); echo $lenght; $IdetificatorArray = array( "1" => "ones" , "2" => "tens" , "3" => "hundreats" , "4" => "tousands" , "5" => "tentousands" , "6" => "houndrettousands" , "7" => "milions" , "8" => "tenmilions" , "9" => "houndretmilions" , "10" => "bilions" ); for ($i = $lenght ; $i > -1 $i-- ) { $valueArray = array( $IdetificatorArray[$i] => (int)$NumberInStringFormat[$i] ); } print_r($valueArray); //1 364 720 434 ?> </body> </html> PS: What I was trying to do is get a array, for example if imput $numberInStringFormat is 345 the array should look like this: [hundreats] => 3; // all of these in int format... [tens] => 4; [ones] => 5; Quote Link to comment Share on other sites More sharing options...
gevans Posted May 27, 2009 Share Posted May 27, 2009 A little bit of looking would've made this a very easy fix for ($i = $lenght ; $i > -1 $i-- ) { should be for ($i = $lenght ; $i > -1; $i-- ) { Quote Link to comment Share on other sites More sharing options...
Paldo Posted May 27, 2009 Author Share Posted May 27, 2009 well sorry for that, but that's not the problem couse the ; is missing only here I have it on my page... I'll fix it right away but the problem stays the same.... Parse error: parse error, expecting `')'' in /3w/euweb.cz/p/parobek/zuzkeconfirm.php on line 29 Here is corected code: <html> <body> <?php $NumberInStringFormat = $_POST[number]; echo $NumberInStringFormat; echo '<br>'; $lenght = strlen($NumberInStringFormat); echo $lenght; $IdetificatorArray = array( "1" => "ones" , "2" => "tens" , "3" => "hundreats" , "4" => "tousands" , "5" => "tentousands" , "6" => "houndrettousands" , "7" => "milions" , "8" => "tenmilions" , "9" => "houndretmilions" , "10" => "bilions" ); for ($i = $lenght ; $i > -1 ; $i-- ) { $valueArray = array( $IdetificatorArray[$i] => (int)$NumberInStringFormat[$i] ); } print_r($valueArray); //1 364 720 434 ?> </body> </html> PS: What I was trying to do is get a array, for example if imput $numberInStringFormat is 345 the array should look like this: [hundreats] => 3; // all of these in int format... [tens] => 4; [ones] => 5; Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 27, 2009 Share Posted May 27, 2009 Okay, I think it's about time you learn to utilize the tag. For your output, change $valueArray = array( $IdetificatorArray[$i] => (int)$NumberInStringFormat[$i] ); to $valueArray[$IdetificatorArray[$i]] = (int)$NumberInStringFormat[$i]; Quote Link to comment Share on other sites More sharing options...
Paldo Posted May 27, 2009 Author Share Posted May 27, 2009 Ok I did what you told me to and now it says: Parse error: parse error in /3w/euweb.cz/p/parobek/zuzkeconfirm.php on line 29 Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 27, 2009 Share Posted May 27, 2009 Could you post an updated version of your code using tags? And also specify where line 29 is. Thanks! Quote Link to comment Share on other sites More sharing options...
Paldo Posted May 27, 2009 Author Share Posted May 27, 2009 Sorry for beeing such a douche. I realy appreciate your help, I'm kind of new in this stuff... <html> <body> <?php $NumberInStringFormat = $_POST[number]; echo $NumberInStringFormat; echo '<br>'; $lenght = strlen($NumberInStringFormat); echo $lenght; echo '<br>'; echo '<br>'; $IdetificatorArray = array( "1" => "ones" , "2" => "tens" , "3" => "houndrets" , "4" => "tousands" , "5" => "tentousands" , "6" => "houndredtousands" , "7" => "milions" , "8" => "tenmilions" , "9" => "houndredmilions" , "10" => "bilions" ); for ($i = $lenght ; $i > -1; $i-- ) { // this is the line that parse error refers to $valueArray[$IdetificatorArray[$i]] = (int)NumberInStringFormat[$i] ; } print_r($valueArray); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted May 28, 2009 Share Posted May 28, 2009 can't see any missing parenthesis but this line for ($i = $lenght ; $i > -1; $i-- ) { // this is the line that parse error refers to should be for ($i = $lenght-1 ; $i = 0 ; $i-- ) { // this is the line that parse error refers to initialize the array before using - that may help... $valueArray=array(); for ($i = $lenght-1 ; $i = 0 ; $i-- ) { // this is the line that parse error refers to Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.