Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/01/2015, 16:21
Avatar de asassa
asassa
 
Fecha de Ingreso: julio-2008
Ubicación: En el DF ectuoso
Mensajes: 240
Antigüedad: 15 años, 9 meses
Puntos: 0
Pregunta como obtener los valores de json

tengo un problema el como poder opbener los contenidos de un json
Código PHP:
//generador de json php2
<?php
       
// $IdAseg=$_POST['ID_ASEGURADORA'];
       //    $IdCampo=1;   
        //echo  $IdCampo;
        
$mysqli = new mysqli("localhost""root""""");
        
//ejemplo $mysqli = ConectarBase();
        
$sql="select ID_ASEGURADORA, ID_CAMPO, VAL_CAMPO, DESC_VALOR, SECUENCIA from ING_VALOR_CAMPO
        where ID_ASEGURADORA=1"
;    
        
$result=  mysqli_query($mysqli$sql); //ejecutamos la consulta
         
        
$first 0;//separa los elementos con una coma
//        $json = '{"data":[';
        
$json '[';        
         while (
$row=mysqli_fetch_array ($result)) {
           
            if (
$first++) $json .=',';
            
$json .= '["'.$row['ID_ASEGURADORA'].'",';
            
$json .= '"'.$row['ID_CAMPO'].'",';
            
$json .= '"'.$row['VAL_CAMPO'].'",';
            
$json .= '"'.$row['DESC_VALOR'].'",';
            
$json .= '"'.$row['SECUENCIA'].'"]';
               
        }
        
$json .= ']';
        print 
$json

?>
Con una salida [["1","38","F","DES","2"],["1","38","V","DES","2"],["1","38","G","DES","2"],["1","39","F","DES","2"],["1","39","V","DES","2"],["1","39","G","DES","2"]] .

pero en mi php1 tengo qeu poder separa el contenido de este json pero no he podido hacerlo he intentado
Código PHP:
//php que reibe los datop
$str_datos file_get_contents("php2.php");
$datos json_decode($str_datos,true);
 
echo 
"Aficiones del jefe: ".$datos["ID_ASEGURADORA"]["ID_CAMPO"]["VAL_CAMPO"]["DESC_VALOR"]["SECUENCIA"][0]."n"
ALGUIEN QUE ME PUEDA AYUDAR . GRACIAS