我有一个像下面这样的数组(数组 1),我需要从中删除 stdClass,就像下面的数组一样。2. 目前我正在使用 foreach 循环进行操作,有没有更好的方法来做到这一点而无需循环?
阵列 1 号
array(3) {
[0] => object(stdClass)#169 (4) {
["id"] => string(2) "59"
["name"] => string(13) "test"
["email"] => string(21) "abc@abc.com"
["telephone"] => string(20) "898998989"
}
[1] => object(stdClass)#190 (4) {
["id"] => string(2) "58"
["name"] => string(13) "test"
["email"] => string(21) "abc@abc.com"
["telephone"] => string(8) "71877858"
}
[2] => object(stdClass)#193 (4) {
["id"] => string(2) "34"
["name"] => string(9) "test"
["email"] => string(22) "abc@abc.com"
["telephone"] => string(13) "3189028092139"
}
}
阵列 2 号
array(3) {
[0] => array(4) {
["id"] => string(2) "62"
["name"] => string(5) "test"
["email"] => string(22) "abc@abc.com"
["telephone"] => string(10) "898998989"
}
[1] => array(4) {
["id"] => string(2) "59"
["name"] => string(13) "test"
["email"] => string(21) "abc@abc.com"
["telephone"] => string(20) "71877858"
}
[2] => array(4) {
["id"] => string(2) "58"
["name"] => string(13) "test"
["email"] => string(21) "abc@abc.com"
["telephone"] => string(8) "3189028092139"
}
}
这就是我所做的(铸造)
foreach($moderationContacts as $contact)
{
$contacts[] = (array)$contact;
}