Entfernen stdClass Objekte aus dem array

Ich habe ein array wie unten (array 1) und ich brauche zu entfernen stdClass von es so wie im unteren Bereich nicht. 2. Zurzeit mache ich es mit einer foreach-Schleife ist, gibt es eine bessere Weise, das zu tun, ohne Schleife?

Array nicht.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"
  }
}

Array nicht.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"
  }
}

Dies ist, was ich Tue (Gießen)

foreach($moderationContacts as $contact)
{
    $contacts[] = (array)$contact;
}
Warum willst du es entfernen?
Sie können die Bearbeitung von arrays ohne Schleife. Jede Lösung muss in irgendeiner form der impliziten Schleife.
Ich brauche zum erstellen einer JSON-Objekt aus über die Funktionen json_encode
Sie können immer noch ein JSON-Objekt aus, keine Notwendigkeit, zu konvertieren, die Objekte in arrays.
richtig ist, genau der Grund, warum ich gefragt wurde

InformationsquelleAutor Shaolin | 2013-05-07

Schreibe einen Kommentar