PHP strpos

Discussion in 'PHP' started by Agent_Smith, Aug 14, 2009.

  1. #1
    Hi,

    Cant work this out:

    	
    foreach($SystemSettings as $var => $val)
    {
    	if($row[1] == "home_title")
    	{
    			
    		$pos = strpos($row[1], "{setting.$var}");
    
    		if ($pos === false) 
    		{
     		   echo "The string '{setting.$var}' was not found in the string 		'".$row[3]."'";
    		} else {
      		  echo "The string '{setting.$var}' was found in the string 	'".$row[3]."'";
    		}
    		echo "<br />";
    	}
    }
    PHP:
    Thank you!
     
    Agent_Smith, Aug 14, 2009 IP
  2. elitasson

    elitasson Member

    Messages:
    49
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #2
    Here is some help perhaps

    $string = "PHP";
    $container = "I love writing PHP code.";
    
    if(strstr($container,$string)) {
    echo "found it.";
    } else {
    echo "not found.";
    }
    PHP:
     
    elitasson, Aug 14, 2009 IP
  3. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #3
            $pos = strpos($row[1], "{setting.$var}");
    PHP:
    should be

            $pos = strpos($row[3], "{setting.$var}");
    PHP:
     
    premiumscripts, Aug 14, 2009 IP
    Agent_Smith likes this.
  4. astrazone

    astrazone Member

    Messages:
    358
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    33
    #4
    echo the setting.$var and $row[0,1,2,3]
    and post it here.

    and by the way, whats the problem?
     
    astrazone, Aug 14, 2009 IP
  5. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Any chance the tokens are from a Smarty template?

    By the way strpos will never match if the encapsulating if block already determined $row[1] is "home_title"
     
    kblessinggr, Aug 14, 2009 IP
  6. Agent_Smith

    Agent_Smith Well-Known Member

    Messages:
    890
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    145
    #6

    Thank you all ^^ feel so stupid :p
     
    Agent_Smith, Aug 15, 2009 IP