Hi everyone,
I am wondering if it is possible to extract the key values of an array into object variables.
lets say i have the following $_REQUEST array:
and the the following object:
how could i use extract, to store the Key=>values into the object variables:
thankyou
I am wondering if it is possible to extract the key values of an array into object variables.
lets say i have the following $_REQUEST array:
Code:
$var_array = array("color" => "blue",
"size" => "medium",
"shape" => "sphere");
extract($var_array, EXTR_IF_EXISTS);
Code:
Class Listener
{
public $color;
public $size;
public function __construct(){
if(isset($_REQUEST)){
extract($_REQUEST, EXTR_IF_EXISTS);
return true;
}
else{
return false;
}
}
}
how could i use extract, to store the Key=>values into the object variables:
Code:
echo $this->color //blue echo $this->size //medium
thankyou
Comment