Problem with an if instruction

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
MeHigh
Forum Newbie
Posts: 13
Joined: Mon Jun 30, 2003 9:31 am

Problem with an if instruction

Post by MeHigh »

I have this code:

Code: Select all

<?php
<?php 
$limbaje = array(0=>"perl", 1=>"PHP", 2=>"Python", 3=>"perl", 4=>"PHP", 5=>"Python");
$cauta = "PHP";
//it searches the $limbaje array the $cauta value
$limita = count($limbaje);
for ($i=0; $i < $limita; $i++)
{
echo "<br> determining a identity with $limbaje[$i]";
	if ($cauta == $limbaje[$i])
		{
		"<br>$cauta is an aprooved language.";
		}
}
?>
?>

and it prints
determining a identity with perl
determining a identity with PHP
determining a identity with Python
determining a identity with perl
determining a identity with PHP
determining a identity with Python
instead off
determining a identity with perl
determining a identity with PHP
PHP is an aprooved language.
determining a identity with Python
determining a identity with perl
determining a identity with PHP
PHP is an aprooved language.
determining a identity with Python
Thx a lot
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

Code: Select all

if ($cauta == $limbaje&#1111;$i]) 
      &#123; 
      echo "<br>$cauta is an aprooved language."; 
      &#125;
santos_
Forum Newbie
Posts: 2
Joined: Wed Jul 09, 2003 4:29 am

Post by santos_ »

Code: Select all

<?php 

	$limbaje = array(0=>"perl", 1=>"PHP", 2=>"Python", 3=>"perl", 4=>"PHP", 5=>"Python"); 
	$cauta = "PHP"; 

	for ($i=0; $i<sizeof($limbaje); $i++) 
	{ 
		echo "determining a identity with " . $limbaje[$i] . "<br>\n";

		if($limbaje[$i] == $cauta){
			echo $limbaje[$i] . " is an approved language.<br>\n";
		}
	} 

?>
User avatar
MeHigh
Forum Newbie
Posts: 13
Joined: Mon Jun 30, 2003 9:31 am

Post by MeHigh »

thanx a lot, guys. :D
Post Reply