| | |
String and integer value comparision??
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Well to add the 10 and NA you will need to convert NA to an integre/number. So the following should do the job:
However you may want to replace $_GET with whatever you already have in place.
php Syntax (Toggle Plain Text)
$var1=str_replace('NA',0,$_GET['input1']); $var2=str_replace('NA',0,$_GET['input2']); $var3=str_replace('NA',0,$_GET['input3']); $var4=str_replace('NA',0,$_GET['input4']); if (($var1+$var2)>($var3+$var4)) { //blah }
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
•
•
Join Date: Apr 2008
Posts: 296
Reputation:
Solved Threads: 11
PHP Syntax (Toggle Plain Text)
echo $var1=10+"NA"; echo"<br>".$var2=10+20;
Output :-
10
30
And i want to show that
10+"NA" > 10+20
I tested the if statement you've suggested and no error occured so I don't see what the problem is. Below is an example of my script.
php Syntax (Toggle Plain Text)
<? if (10+"NA" > 10+20) { echo 'passed if'; } else { echo 'failed if'; } ?>
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
•
•
Join Date: Apr 2008
Posts: 296
Reputation:
Solved Threads: 11
Hi, cwarn23
Out put out your program is :- failed if
I want here output :- passed if
I give the explanation what i want
10 + "Na"= 10 and 10 +20=30
But NA means not applicable we can't consider as value
so we use as 10+20 i.e 30 in processing.
So i want to show (10+"NA") > (10+20)
How to do this????
Out put out your program is :- failed if
I want here output :- passed if
I give the explanation what i want
10 + "Na"= 10 and 10 +20=30
But NA means not applicable we can't consider as value
so we use as 10+20 i.e 30 in processing.
So i want to show (10+"NA") > (10+20)
How to do this????
If you just want the opposite result then the following should do the job.
php Syntax (Toggle Plain Text)
<? if (10+"NA" < 10+20) { echo 'passed if'; } else { echo 'failed if'; } ?>
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
![]() |
Similar Threads
- Converting String to Integer (C)
- How to add string to an integer variable... (C++)
- how to convert a string to integer (HTML and CSS)
- string to integer OR float (C++)
- to convert string to integer value (Legacy and Other Languages)
- String to integer conversion (C)
- Convert a string to an integer (PHP)
- Converting String to Integer help (C++)
- String to integer to ascii (C)
Other Threads in the PHP Forum
- Previous Thread: My database connection dies but doesnt print an error
- Next Thread: SESSION LIFE( TIME) problem
Views: 549 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email error execution file files folder form forms function functions google href htaccess html htmlspecialchars image include insert integration ip java javascript joomla jquery limit link links login loop mail menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote replace script search select server session sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube






