Muddy_Funster Posted April 17, 2012 Share Posted April 17, 2012 is this enough? : function custOut($val){ //declare function to check values, take in any variable passed to it and assign it to $val while it's inside the function if (is_array($val)){ // check if the variable that was passed in is an array, if it is foreach($val as $k=> $v){ //run through the array, assigning the keys as $k and the vaules as $v if(trim($v) == '' || empty($v) || !isset($v)){ //if the value (once all empty space has been removed) is an empty string, or if the value is false, or if the value is not set $v = 'N/A'; //make the value = to the string 'N/A' }//close if value check }//close for each } //cloase if array else{ // if the value passed in is not an array if(trim($val) == '' || empty($val) || !isset($val)){ //perform the same check directly to the value that was passed into the function $val = 'N/A'; // and applt the string value of 'N/A' if it matches the check }//close if check }//close else return $val; //now that we are done we can return the value of $val back to the main code, only changed if it met with the checks and exactly as it was if it didn't } // end of function. nb. If we didn't return anything the rest of the code would have no access any changes made in the function Link to comment https://forums.phpfreaks.com/topic/260798-php-search-form-help/page/3/#findComment-1338048 Share on other sites More sharing options...
blepblep Posted April 17, 2012 Author Share Posted April 17, 2012 Yeah thats perfect, thanks alot!! I have some other stuff now to try and implement on search, I wont ask as you've answered enough, I'll try it now and see how it goes. Link to comment https://forums.phpfreaks.com/topic/260798-php-search-form-help/page/3/#findComment-1338051 Share on other sites More sharing options...
Muddy_Funster Posted April 17, 2012 Share Posted April 17, 2012 I always find it best to have a stab it it myself first. pop back and start another thread if your having any more problems. good luck Link to comment https://forums.phpfreaks.com/topic/260798-php-search-form-help/page/3/#findComment-1338054 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.