One if statement works, one doesn't!

One if statement works, one doesn't!!

Page 1 of 1

1 Replies - 680 Views - Last Post: 18 June 2010 - 07:19 AM Rate Topic: -----

#1 Zugzwangle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-June 10

One if statement works, one doesn't!

Posted 18 June 2010 - 06:45 AM

$parts[] is an array of the following:
 [Event \"90m + 5s, rated\"
 [Site \"Main Playing Hall\" 
 [Date \"2010.06.17\" 
 [Round \"?\" 
 [White \"Zugzwang1\" 
 [Black \"Jeff Morris\" 
 [Result \"0-1\" 
 [WhiteElo \"1189\" 
 [BlackElo \"1233\" 
 [PlyCount \"30\" 
 EventDate \"2010.06.17\" 
 [EventType \"blitz\" 
 [TimeControl \"60\" 



The first for statement below works.. the 2nd doesn't, yet $partsLocation and $correctLocation are the same value, as tested with an echo statement (echo ($partsLocation).'<br>'; echo ($correctLocation);).
<?php
$correctControl = '[Event \"90m + 5s, rated\"';
	$partsControl = $parts[0];
	//echo ($partsControl.'<br>');
	//echo ($correctControl.'<br>');
	if ($partsControl == $correctControl)
	{
		echo ("Correct time control!!<br>");
	}
	 else 
	{
	echo ("Time Control is wrong!!!");
	}

	
	$correctLocation = '[Site \"Room 1\"'; 
	$partsLocation = $parts[1];
	//echo ($partsLocation).'<br>';
	//echo ($correctLocation);
	if ($partsLocation == $correctLocation)
	{
		echo "Correct Location";
	}
	else 
	{
	echo ("Location is wrong!!!<br>");
	}
?>

OUTPUTS:
Correct time control!!
Location is wrong!!!


The first for statement works, and the 2nd doesn't.. I can't see why. Can you?

This post has been edited by Zugzwangle: 18 June 2010 - 06:48 AM


Is This A Good Question/Topic? 0
  • +

Replies To: One if statement works, one doesn't!

#2 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2881
  • View blog
  • Posts: 9,948
  • Joined: 08-August 08

Re: One if statement works, one doesn't!

Posted 18 June 2010 - 07:19 AM

I see that it is working.


[Site \"Main Playing Hall\"
doe not equal
[Site \"Room 1\"

By the way, I think you intended to use an associative array. If so, you need to read up on them.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1