Jump to content

a foreach question from PHP solutions


splintercell

Recommended Posts

here is part of the code:

 

// process the $_POST variables

foreach ($_POST as $key => $value) {

// assign to temporary variable and strip whitespace if not an array

$temp = is_array($value) ? $value : trim($value);

// if empty and required, add to $missing array

if (empty($temp) && in_array($key, $required)) {

array_push($missing, $key);

}

// otherwise, assign to a variable of the same name as $key

elseif (in_array($key, $expected)) {

${$key} = $temp;

}

}

 

what is $temp = is_array($value) ? $value : trim($value); doing? I thought is_array($value) always evaluates to false because $value is never an array(the values are submitted in a form). Please help

 

Link to comment
https://forums.phpfreaks.com/topic/170371-a-foreach-question-from-php-solutions/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.