1 2 3 4 5 6 7 8 9 10 11 12 13 14
<?php $array = array("playlist"=> 8002, "mp3"=>1024); class Mix { public function __construct($array) { foreach($array as $key => $value) { $this->$key = $value; } } } $class = new Mix($array); var_dump($class);
1 2 3 4 5 6
object(Mix)#1 (2) { ["playlist"]=> int(8002) ["mp3"]=> int(1024) }