- addslashes: documentation ( source)
- str_replace: documentation ( source)
- strtolower: documentation ( source)
<?php
$test = array('customer-test1' => 1, 'customer-test2' => 2);
function getPost($param) {
global $test;
echo addslashes($param)." = ".$test[$param]."<br/>";
return isset($test[$param]) ? $test[$param] : NULL;
}
class Customer {
private $test1;
private $test2;
function __construct() { }
}
$object = new Customer();
$arr = (array)$object;
$newArr = array();
foreach($arr as $key => $val) {
$newKey = str_replace(get_class($object), "", $key);
$newArr[$newKey] = getPost(strtolower(get_class($object))."-".$newKey);
}