User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » php help.... Page [1]  
stephen_tl
All American
611 Posts
user info
edit post

I have no idea what i'm doing wrong with the if statement, I changed it so many ways. No matter what the word is it keeps going to True....Probably something simple and i'm not seeing it...

while($j < $i){
if ($final[$j] == "Interval" || "Large") {
echo "True$final[$j]";
}else{
echo "false$final[$j] $whitespaceten $final[$k] $whitespaceten $final[$l]<br>";

++$l;
++$k;
}
$m=$j;
++$j;

}

10/21/2008 10:19:29 AM

qntmfred
retired
40552 Posts
user info
edit post

order of operations

it is equivalent to if( ($final[$j] == "Interval") || ("Large"))

"Large" by itself will evaluate to true. also, use strcmp on both strings

if (!strcmp($final[$j], "Interval") || !strcmp($final[$j], "Large"))

[Edited on October 21, 2008 at 10:25 AM. Reason : .]

10/21/2008 10:22:18 AM

stephen_tl
All American
611 Posts
user info
edit post

forgot to mention i just used two words but i want to compare that one word to like 20 different words.

10/21/2008 10:26:08 AM

BigMan157
no u
103352 Posts
user info
edit post

if(in_array($final[$j], array("Interval", "Large", "so on", "so forth", "etc")))

10/21/2008 10:27:40 AM

stephen_tl
All American
611 Posts
user info
edit post

oh thanks a lot.

10/21/2008 10:30:30 AM

gs7
All American
2354 Posts
user info
edit post

You're welcome.

10/21/2008 10:50:11 AM

 Message Boards » Tech Talk » php help.... Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.38 - our disclaimer.