Hi PHP John,
You beat me too it... for your reference I solved it similarly;
PHP Code:
<?php
$o_Doit = null;
$o_Doit = new Doit();
$customer = null;
$customer = array(
'dealerId' => 4
,'billFirstName' => 'Joe'
,'billLastName' => 'Blo'
,'billAddress1' => '1010s'
,'billAddress2' => '1020s'
,'billCity' => 'Anytown'
,'billState' => 'ST'
,'billCountry' => 'USA'
,'billPostalCode' => 11111
,'dEmail' => 'emailaddress'
,'billPhone' => 8008008888
,'password' => 'password'
,'distPrice' => 5
,'distCost' => 20
);
$result = null;
$result = $o_Doit->keyCheck('dealerId', $customer);
if($result){
echo $result;
} else {
echo 'Result not found.';
}
class Doit{
protected $p_array;
public function __construct(){
$this->p_array = null;
}
public function keyCheck($key, $array, $type = false){
$this->p_array = $array;
$this->{$key} = $this->p_array[$key]; //Dynamical set the property variable
if(array_key_exists($key, $this->p_array) && $this->p_array[$key]):
return $this->p_array[$key];
else:
return $type;
endif;
}
}
?>
Regards,
Steve
Bookmarks