Ver Mensaje Individual
  #6 (permalink)  
Antiguo 22/09/2016, 21:33
Avatar de pateketrueke
pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: ¿Cómo iterar sobre un jSON?

Pues la sintaxis que muestras ni siquiera es válida.

Código PHP:
Ver original
  1. $miarray = array(
  2.   0 => "{
  3.    "metadata.title": "",
  4.    "metadata.description": "",
  5.    "metadata.keywords": "",
  6.    "metadata.robots": "",
  7.    "metadata.author": "",
  8.    "config.enable_comments": "0",
  9.    "config.primary_category": "27"
  10.    }",
  11.   1 => "{
  12.    "metadata.title": "",
  13.    "metadata.description": "",
  14.    "metadata.keywords": "",
  15.    "metadata.robots": "",
  16.    "metadata.author": "",
  17.    "config.enable_comments": "0",
  18.    "config.primary_category": "27"
  19.    }"
  20. );

Además, aunque lo niegues, las claves del código JSON original no son numéricas, observa:
Código PHP:
Ver original
  1. $json = <<<JSON
  2.  
  3. {
  4.     "metadata.title": "",
  5.     "metadata.description": "",
  6.     "metadata.keywords": "",
  7.     "metadata.robots": "",
  8.     "metadata.author": "",
  9.     "config.enable_comments": "0",
  10.     "config.primary_category": "27"
  11. }
  12.  
  13. JSON;
  14.  
  15. $data = json_decode($json, true);
  16.  
  17. echo $data['config.primary_category']; // 27

Cita:
no, sí son numéricos
¿Seguro?
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.