データ構造($test_rec)
array(1) { [0]=> object(Record)#386 (10) { ["seq"]=> string(2) "27" ["cd"]=> string(1) "7" ["no"]=> string(2) "67" ["date"]=> string(8) "20180105" ["count"]=> string(1) "1" ["records"]=> string(6518) "<?xml version="1.0" encoding="UTF-8"?> <テスト履歴><テスト></テスト></テスト履歴> " ["delete_flg"]=> string(1) "0" ["create_date"]=> string(14) "20180105085951" ["update_date"]=> NULL ["delete_date"]=> NULL } } array(0) { } array(1) { [0]=> object(Record)#377 (10) { ["seq"]=> string(4) "2581" ["cd"]=> string(1) "7" ["no"]=> string(1) "3" ["date"]=> string(8) "20180105" ["count"]=> string(1) "1" ["records"]=> string(2308) "<?xml version="1.0" encoding="UTF-8"?> <テスト履歴><テスト></テスト></テスト履歴> " ["delete_flg"]=> string(1) "0" ["create_date"]=> string(14) "20180105090009" ["update_date"]=> NULL ["delete_date"]=> NULL } } array(0) { }
のようなデータがあります($test_rec)。
■arrayにデータが入っているもののみを抽出したく、
php
1foreach ($test_rec as $k => $v) { 2 if(!empty($v->records)){ 3 $test_list[] = array( 4 'seq' => $v->seq, 5 'cd' => $v->cd, 6 'no' => $v->no, 7 ); 8 } 9}
としましたが、値が入ってこないです。どのようにしたらいいいか
ご教授宜しくお願いします。
$test_recを回答者が参照できる形でプログラムとして書いて下さい
回答1件
あなたの回答
tips
プレビュー