Notice: Undefined offset: 0 in C: \ xampp \ htdocs \ www \ SERVICESUNARP \ index.php on line 57

0

I have this arrangement that comes as a response from a webservice

var_dump=$miarreglo;

result:

array(1) { 

["respuestaTitularidad"]=> array(4) 
{ 

[0]=> array(10) 
{ 
    ["registro"]=> string(30) "REGISTRO DE PROPIEDAD INMUEBLE" 
    ["libro"]=> string(19) "REGISTRO DE PREDIOS" 
    ["apPaterno"]=> string(7) "SANCHEZ" 
    ["apMaterno"]=> string(5) "ROJAS" 
    ["nombre"]=> string(15) "JORGE EDILBERTO" 
    ["numeroPartida"]=> string(8) "45043150" 
    ["estado"]=> string(6) "ACTIVA" 
    ["zona"]=> string(29) "ZONA REGISTRAL IX - SEDE LIMA" 
    ["oficina"]=> string(4) "LIMA" 
    ["direccion"]=> string(85) "CALLE LOS AGRICOLAS MZ R LOTE 33 , LAS ACACIAS DE MONTERRICO LA MOLINA - LIMA - LIMA" 
} 


[1]=> array(10) 
{ 
    ["registro"]=> string(30) "REGISTRO DE PROPIEDAD INMUEBLE" 
    ["libro"]=> string(19) "REGISTRO DE PREDIOS" 
    ["apPaterno"]=> string(7) "SANCHEZ" 
    ["apMaterno"]=> string(5) "ROJAS" 
    ["nombre"]=> string(5) "JORGE" 
    ["numeroPartida"]=> string(8) "43140671" 
    ["estado"]=> string(6) "ACTIVA" 
    ["zona"]=> string(29) "ZONA REGISTRAL IX - SEDE LIMA" 
    ["oficina"]=> string(4) "LIMA" 
    ["direccion"]=> string(84) "JIRON LAS ANEMONAS MZ 54 LOTE 14 URB LAS FLORES SAN JUAN DE LURIGANCHO - LIMA - LIMA" 
} 

[2]=> array(13) { 
    ["registro"]=> string(26) "REGISTRO DE BIENES MUEBLES" 
    ["libro"]=> string(31) "REGISTRO DE PROPIEDAD VEHICULAR" 
    ["apPaterno"]=> string(7) "SANCHEZ" 
    ["apMaterno"]=> string(5) "ROJAS" 
    ["nombre"]=> string(10) "JORGE LUIS" 
    ["tipoDocumento"]=> string(8) "C.M. " 
    ["numeroDocumento"]=> string(9) "116770700" 
    ["numeroPartida"]=> string(8) "50438525" 
    ["numeroPlaca"]=> string(7) "HG5186 " 
    ["estado"]=> string(6) "ACTIVA" 
    ["zona"]=> string(29) "ZONA REGISTRAL IX - SEDE LIMA" 
    ["oficina"]=> string(4) "LIMA" 
    ["direccion"]=> string(9) "#########" 
}

 [3]=> array(13) { 
     ["registro"]=> string(26) "REGISTRO DE BIENES MUEBLES" 
     ["libro"]=> string(31) "REGISTRO DE PROPIEDAD VEHICULAR" 
     ["apPaterno"]=> string(7) "SANCHEZ" 
     ["apMaterno"]=> string(5) "ROJAS" 
     ["nombre"]=> string(12) "JORGE MARTIN" 
     ["tipoDocumento"]=> string(3) "DNI" 
     ["numeroDocumento"]=> string(8) "44617981" 
     ["numeroPartida"]=> string(8) "51030901" 
     ["numeroPlaca"]=> string(7) "BIA898 " 
     ["estado"]=> string(6) "ACTIVA" 
     ["zona"]=> string(29) "ZONA REGISTRAL IX - SEDE LIMA" 
     ["oficina"]=> string(4) "LIMA" 
     ["direccion"]=> string(9) "#########" 
 } 


} 
}

How can I read the array data? since I need to put the information in tables, since the following code does not work for me.

<?php foreach ($miarreglo as $data) {  ?>

<tr> 

  <td><center><?php echo $data->registro;   ?></center> </td>
  <td><center><?php echo $data->libro;   ?></center> </td>
  <td><center><?php echo $data->apPaterno;   ?></center> </td>
  <td><center><?php echo $data->apMaterno;   ?></center> </td>
  <td><center> <?php echo $data->nombre;  ?></center> </td>
  <td><center> <?php echo $data->numeroPartida;  ?></center> </td>
  <td><center><?php echo  $data->estado;   ?></center> </td>
  <td><center><?php echo $data->zona;   ?></center> </td>
    <td><center><?php echo  $data->oficina;   ?></center> </td>
  <td><center><?php echo $data->direccion;   ?></center> </td>
</tr>

<?php } ?>
  

Notice: Undefined index: record in C: \ xampp \ htdocs \ www \ SERVICESUNARP \ index.php on line 55

    
asked by Gino H. Caycho 15.11.2017 в 22:48
source

2 answers

3

If you look closely you have the array that you want to print within another array , so you should do the following:

<?php foreach ($miarreglo['respuestaTitularidad'] as $data) {  ?>

<tr> 
  <td><center><?php echo $data['registro']; ?></center> </td>
  <td><center><?php echo $data['libro']; ?></center> </td>
  <td><center><?php echo $data['apPaterno']; ?></center> </td>
  <td><center><?php echo $data['apMaterno']; ?></center> </td>
  <td><center> <?php echo $data['nombre'];?></center> </td>
  <td><center> <?php echo $data['numeroPartida'];?></center> </td>
  <td><center><?php echo  $data['estado']; ?></center> </td>
  <td><center><?php echo $data['zona']; ?></center> </td>
  <td><center><?php echo  $data['oficina']; ?></center> </td>
  <td><center><?php echo $data['direccion']; ?></center> </td>
</tr>

<?php } ?>
    
answered by 15.11.2017 / 23:09
source
1

It would be as follows: <?php foreach ($miarreglo as $data) { ?> <tr>

< td > < center > <? php echo $ data ['record']; ? > < / center > < / td > < td > < center > <? php echo $ data ['book']; ? > < / center > < / td > < td > < center > <? php echo $ data ['apPaterno']; ? > < / center > < / td > < td > < center > <? php echo $ data ['apMaterno']; ? > < / center > < / td > < td > < center > <? php echo $ data ['name']; ? > < / center > < / td > < td > < center > <? php echo $ data ['partNumber']; ? > < / center > < / td > < td > < center > <? php echo $ data ['status']; ? > < / center > < / td > < td > < center > <? php echo $ data ['zone']; ? > < / center > < / td > < td > < center > <? php echo $ data ['office']; ? > < / center > < / td > < td > < center > <? php echo $ data ['address']; ? > < / center > < / td > < / tr > <? php}? >

Greetings.

    
answered by 15.11.2017 в 22:56