Re: [PHP] cant get if logic correct..
is_integer probably wouldn't work, since you're dealing with strings here. Your best friend here would probably be 'is_numeric' which would return true on both the string '1' as the integer 1 true. As well as 1.1 and '1.1'. The only one solution I could think if would be: preg_match('/^\d+$/', $stnr); -- Ain't it always the small things like this that consume too much time? On 17/08/07, Sanjeev N <[EMAIL PROTECTED]> wrote: > > Why don't you try to check for if it is integer. You will get the function > to check the variable (is_integer not sure) in manual. > > Warm Regards, > Sanjeev > http://www.sanchanworld.com > http://webdirectory.sanchanworld.com - Submit your website URL > http://webhosting.sanchanworld.com - Choose your best web hosting plan > > -Original Message- > From: Gregory Machin [mailto:[EMAIL PROTECTED] > Sent: Wednesday, August 15, 2007 7:01 PM > To: php-general@lists.php.net > Subject: [PHP] cant get if logic correct.. > > Hi > i have a piece of code that gets info from a comma delimited file, > then gets each value that is to be insterted into the database > > The variabls must only contain numbers and must not be null .. > but the logic i have is iether not working or there are some hidden > characters creeping in because it is processing the data ... how can i > do this better ? > > > for($i=2;$i<$arrsize;$i++){ > $parts=explode(",",$lines[$i]); > $stnr=$parts[0]; > $subj=$parts[1]; > $mark=$parts[4]; > if (($stnr>"") and ($subj>"") and ($mark>"")){ >//do alot of something lol >} >} > > -- > Gregory Machin > > -- > 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 > > -- Interpotential.com Phone: +31615397471
RE: [PHP] cant get if logic correct..
Why don't you try to check for if it is integer. You will get the function to check the variable (is_integer not sure) in manual. Warm Regards, Sanjeev http://www.sanchanworld.com http://webdirectory.sanchanworld.com - Submit your website URL http://webhosting.sanchanworld.com - Choose your best web hosting plan -Original Message- From: Gregory Machin [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 15, 2007 7:01 PM To: php-general@lists.php.net Subject: [PHP] cant get if logic correct.. Hi i have a piece of code that gets info from a comma delimited file, then gets each value that is to be insterted into the database The variabls must only contain numbers and must not be null .. but the logic i have is iether not working or there are some hidden characters creeping in because it is processing the data ... how can i do this better ? for($i=2;$i<$arrsize;$i++){ $parts=explode(",",$lines[$i]); $stnr=$parts[0]; $subj=$parts[1]; $mark=$parts[4]; if (($stnr>"") and ($subj>"") and ($mark>"")){ //do alot of something lol } } -- Gregory Machin -- 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] cant get if logic correct..
Gregory Machin wrote: Hi i have a piece of code that gets info from a comma delimited file, then gets each value that is to be insterted into the database The variabls must only contain numbers and must not be null .. but the logic i have is iether not working or there are some hidden characters creeping in because it is processing the data ... how can i do this better ? for($i=2;$i<$arrsize;$i++){ $parts=explode(",",$lines[$i]); $stnr=$parts[0]; $subj=$parts[1]; $mark=$parts[4]; if (($stnr>"") and ($subj>"") and ($mark>"")){ //do alot of something lol } } for ( $i=2; $i<$arrsize; $i++ ) { // Explode string into what you need list($stnr, $subj, $mark) = explode(',', $lines[$i]); // Test for conditions if ( !empty($stnr) && !empty($subj) && !empty($mark) ) { // Do a lot of something lol } else { // Something was empty } } -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cant get if logic correct..
This will be of help. http://us2.php.net/manual/en/function.is-numeric.php On 8/15/07, Gregory Machin <[EMAIL PROTECTED]> wrote: > Hi > i have a piece of code that gets info from a comma delimited file, > then gets each value that is to be insterted into the database > > The variabls must only contain numbers and must not be null .. > but the logic i have is iether not working or there are some hidden > characters creeping in because it is processing the data ... how can i > do this better ? > > > for($i=2;$i<$arrsize;$i++){ > $parts=explode(",",$lines[$i]); > $stnr=$parts[0]; > $subj=$parts[1]; > $mark=$parts[4]; > if (($stnr>"") and ($subj>"") and ($mark>"")){ >//do alot of something lol >} >} > > -- > Gregory Machin > > -- > 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
[PHP] cant get if logic correct..
Hi i have a piece of code that gets info from a comma delimited file, then gets each value that is to be insterted into the database The variabls must only contain numbers and must not be null .. but the logic i have is iether not working or there are some hidden characters creeping in because it is processing the data ... how can i do this better ? for($i=2;$i<$arrsize;$i++){ $parts=explode(",",$lines[$i]); $stnr=$parts[0]; $subj=$parts[1]; $mark=$parts[4]; if (($stnr>"") and ($subj>"") and ($mark>"")){ //do alot of something lol } } -- Gregory Machin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php