Skip to content

Instantly share code, notes, and snippets.

@sifue
Created July 4, 2012 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sifue/3046984 to your computer and use it in GitHub Desktop.
Save sifue/3046984 to your computer and use it in GitHub Desktop.
PHPで、配列にキャストしたオブジェクトのプロパティからクラス名を取り除く ref: http://qiita.com/items/dbf0775984159bf98505
$pre_array_object = (array)$original_object;
$array_object = array();
foreach ($pre_array_object as $key => $value) {
$splited_key = preg_split("/[\\x0]/", $key); // 配列化すると"\u0000クラス名\u0000キー名"となるため処理
$array_object[$splited_key[2]] = $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment