<?php
$a = array('f-stat,porcelain mask'=>'jay azima','jay azima,oil painting'=>'japanese doll');
$msg="We can't recommend any items to you.";
foreach($a as $k=>$v)
{
if($_GET['items']==$k)
{
header("location: hola.php?tequilla=".$v);
}
}
header("location: hola.php?tequilla=".$msg);
?>
What I tried to do is if string from $_GET['items'] matches any of key in $a array, it is redirected to hola.php with $v value. Otherwise $msg string is passed. But the problem is even if the $k and $_GET['items'] matches, latter header function is executed with $msg value. Also if I remove the latter header function, the header function inside the loop works fine.
exit();after theheaderlines so the script doesn't continue to run.die();... I can be morbid like that - but it's the same thing.var_dump($_GET['items']);andtrim()to make sure you do not have any spaces or to count characters while you are comparing string in your if condition.$_GET['items']==$kseriously?