Jump to content

PHP Search Form - Help


blepblep

Recommended Posts

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
Share on other sites

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.