[ create a new paste ] login | about

Link: http://codepad.org/JTExIeOr    [ raw code | output | fork ]

PHP, pasted on May 28:
1
2
3
4
5
6
7
8
9
10
<?php
$params = array('age'=>7, 'height'=>10);
$obj = new stdClass();
foreach ($params as $key=>$value)
{
 $key = '_'.$key;
 $obj->$key=$value;
}
print_r($obj);
?>


Output:
1
2
3
4
5
stdClass Object
(
    [_age] => 7
    [_height] => 10
)


Create a new paste based on this one


Comments: