Ver Mensaje Individual
  #3 (permalink)  
Antiguo 15/07/2016, 07:25
Avatar de hhs
hhs
Colaborador
 
Fecha de Ingreso: junio-2013
Ubicación: México
Mensajes: 2.995
Antigüedad: 10 años, 9 meses
Puntos: 379
Respuesta: ¿Cómo iterar sobre un jSON?

En realidad es muy simple utiliza json_decode con el segundo argumento a true.
Código PHP:
Ver original
  1. $json = '{
  2.  
  3.    "metadata.title": "",
  4.  
  5.    "metadata.description": "",
  6.  
  7.    "metadata.keywords": "",
  8.  
  9.    "metadata.robots": "",
  10.  
  11.    "metadata.author": "",
  12.  
  13.    "config.enable_comments": "0",
  14.  
  15.    "config.primary_category": "27"
  16.  
  17. }';
  18.  
  19. $decode = json_decode($json, true);
  20.  
  21. $category = $decode['config.primary_category'];
  22.  
  23. print_r($category); //print 27
__________________
Saludos
About me
Laraveles
A class should have only one reason to change.