5
私は以下のような配列(配列1)を持っています。配列の下のようにstdClassを削除する必要があります。 2.現在、私はforeachループを使ってやっていますが、ループを繰り返すより良い方法がありますか?配列からstdClassオブジェクトを削除する
アレイ1番
array(3) {
[0] => object(stdClass)#169 (4) {
["id"] => string(2) "59"
["name"] => string(13) "test"
["email"] => string(21) "[email protected]"
["telephone"] => string(20) "898998989"
}
[1] => object(stdClass)#190 (4) {
["id"] => string(2) "58"
["name"] => string(13) "test"
["email"] => string(21) "[email protected]"
["telephone"] => string(8) "71877858"
}
[2] => object(stdClass)#193 (4) {
["id"] => string(2) "34"
["name"] => string(9) "test"
["email"] => string(22) "[email protected]"
["telephone"] => string(13) "3189028092139"
}
}
配列番号2
array(3) {
[0] => array(4) {
["id"] => string(2) "62"
["name"] => string(5) "test"
["email"] => string(22) "[email protected]"
["telephone"] => string(10) "898998989"
}
[1] => array(4) {
["id"] => string(2) "59"
["name"] => string(13) "test"
["email"] => string(21) "[email protected]"
["telephone"] => string(20) "71877858"
}
[2] => array(4) {
["id"] => string(2) "58"
["name"] => string(13) "test"
["email"] => string(21) "[email protected]"
["telephone"] => string(8) "3189028092139"
}
}
は、これは私が何をすべきかです(鋳造)
foreach($moderationContacts as $contact)
{
$contacts[] = (array)$contact;
}
なぜそれを削除しますか? – Bananam00n
ループせずに配列を操作することはできません。どのような解決策でも何らかの形式の暗黙的なループが必要になります。 – deceze
@ Bananam00n - json_encodeを使用してJSONオブジェクトを作成する必要があります – Shaolin