0

I have some functions that returns nothing or some value (obvious), and also having a little trouble with the if and closing, is there a good way to do this? I want to return the value after checking if any of the strings are not empty.
Actually it is a search results page. I can have result by links that follow this structure:

search_url(array("xxx" => "name");

and in the array for xxx's is either:

"sPattern"=> "name"
"sRegion"=> "name"
"sCity"=> "name"

so how to do this?

<?php if( sPattern > '') { ?> 
echo  result
else
<?php if( sRegion > '') { ?> 
echo result
else
<?php if( sCity > '') { ?> 
echo result
if nothing match do this
3
Contributors
4
Replies
27
Views
4 Years
Discussion Span
Last Post by diafol
0

I'm not sure what you're trying to do, but maybe:

if(in_array($name, $array)){
    echo "found";
}else{
    echo "not found";
}
0

Maybe this could help or else could you please elaborate your requirement

search_url(array("xxx" => "name"));

function search_url($air){
    if ( empty($air) ) {
        echo "Empty";
    } else if( $air['sPattern'] ) { 
        echo  $result1;
    } else if( $air['sRegion'] ) { 
        echo $result2;
    } else if( $air['sNname'] ) { 
        echo $result3;
    }
}

Edited by code_rum

0

ok, first there is a search form that takes the sPattern:

<input type="text" name="sPattern"  id="query" class="input-text" value="" etc.

then, there are search links, example:

search_url(array("sRegion" => "florida"));

where the xxx I talked about can be sRegion, sCity or sCategory
"name" can be anything e.g. a name of the category, city, region, whatever I put in there.

All links and search activity goes to results-page.
Then, if results are not found I need to echo this like "there are no results found for "name".
In order to do this I need to check if sPattern, sRegion or sCity was used.
Of course, the value for sPattern can be retrieved from it's function through the search form.
If that is emtpy I need to check which of the others was used from the the links.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.