Hi - I'm trying to get the following code to work though annoyingly it's failing silently - is there anything wrong with the logic?

		$cities = array("San Francisco", "Los Angeles");
			$makes = array("Sony Ericsson", "Nokia");
			$sony = array("W910i", "W850i", "W880i", "W890i", "K770i", "K800i", "K810i", "C902");
			$nokia = array("N95", "N95 8GB", "N73", "N78", "6300");

		if (in_array($makes, $device_make, TRUE) && in_array($sony, $device_model, TRUE) && in_array($cities, Los Angeles, TRUE)) {
		header("Location: $dlurl");

		elseif (in_array($makes, $device_make, TRUE) && in_array($nokia, $device_model, TRUE) && in_array($cities, Los Angeles, TRUE)) {
		header("Location: $dlurl");

		else {
		header( "Location: /register/thankyou");
		}

Another question would be on how to combine is_array statements, ie, is this possible?:

if (in_array($makes, $device_make, TRUE) && in_array($sony, $device_model, TRUE) && in_array($cities, Bristol, TRUE) || in_array($makes, $device_make, TRUE) && in_array($nokia, $device_model, TRUE) && in_array($cities, Bristol, TRUE))

Many thanks.

    When things are "annoyingly silent", try adding the following debug code before the problematic code:

    ini_set('display_errors', 1); // set to 0 for production code
    error_reporting(E_ALL);
    

    As to combining your in_array() calls, yes you can, but you'll need some parentheses to separate the 2 sections:

    if ( ( in_array($x, $arr1) && in_array($x, $arr2) ) || ( in_array($y, $arr2) && in_array($y, $arr3) ) )
    {
       // . . .
    }
    

      PS: To be HTTP 1.1-compliant, the values for your "Location:" headers should be complete URL's, not relative URL's.

        Thanks chaps = NogDog - your code works like a charm.

          Write a Reply...