Loop Multidimensional array in ControllerLaravel Array Validation Message ValueRetrieving old Check-box arrayHow to pass parameters between controller methodsLaravel Change output of the view in controllerFatal error: Class 'AppHttpControllersRedirect' not foundLaravel 5.1 DB::table chunk for a Restful API and Angular.JSEloquent create says column has no default value using Laravel 5How do I convert an API resource class in Laravel 5.5 to an array BEFORE returning from controller?Get values from a deeper nested multi dimension arrayFetch form_params data from Guzzle post request in lumen api

Hashing password to increase entropy

Has the laser at Magurele, Romania reached a tenth of the Sun's power?

How can I, as DM, avoid the Conga Line of Death occurring when implementing some form of flanking rule?

If the Dominion rule using their Jem'Hadar troops, why is their life expectancy so low?

What do the positive and negative (+/-) transmit and receive pins mean on Ethernet cables?

C++ lambda syntax

Do native speakers use "ultima" and "proxima" frequently in spoken English?

Why is participating in the European Parliamentary elections used as a threat?

Why does a 97 / 92 key piano exist by Bosendorfer?

Extract substring according to regexp with sed or grep

Reason why a kingside attack is not justified

Why doesn't Gödel's incompleteness theorem apply to false statements?

Why is indicated airspeed rather than ground speed used during the takeoff roll?

New Order #2: Turn My Way

Why didn’t Eve recognize the little cockroach as a living organism?

Can a Knock spell open the door to Mordenkainen's Magnificent Mansion?

What (if any) is the reason to buy in small local stores?

Can you describe someone as luxurious? As in someone who likes luxurious things?

Do I have to take mana from my deck or hand when tapping this card?

Does capillary rise violate hydrostatic paradox?

Trouble reading roman numeral notation with flats

Should a narrator ever describe things based on a character's view instead of facts?

Capacitor electron flow

Friend wants my recommendation but I don't want to give it to him



Loop Multidimensional array in Controller


Laravel Array Validation Message ValueRetrieving old Check-box arrayHow to pass parameters between controller methodsLaravel Change output of the view in controllerFatal error: Class 'AppHttpControllersRedirect' not foundLaravel 5.1 DB::table chunk for a Restful API and Angular.JSEloquent create says column has no default value using Laravel 5How do I convert an API resource class in Laravel 5.5 to an array BEFORE returning from controller?Get values from a deeper nested multi dimension arrayFetch form_params data from Guzzle post request in lumen api













0















I need to loop in a mulitidemnsional array being consumed in an outbound API. After consuming the API in a controller, I need to insert the looped records in a Model.



So, the response recieved from the external API is the following:



enter image description here



So, what Im doing in my controller function is the following:



public function index()


$client = new GuzzleHttpClient();
$response = $client->request('GET', 'http://api', [
'headers' => [
'x-authtoken' => '0275d',
'cache-control' => 'no-cache'],
'decode_content' => false
]);

//get body content
$body = $response->getBody()->getContents();
$data = json_decode($body, true);

foreach ( $data['content']['Propiedades'] as $propiedades )

$id = Arr::get($propiedades, 'Id');
$Moneda = Arr::get($propiedades, 'Precio.Moneda');
$Precio = Arr::get($propiedades, 'Precio.Valor')





The problem is that im looping just one instance of "propiedades" array.



enter image description here



1. How can I loop all "propiedades" array and retrieve key values from it?



2. How can access each "propiedades" array to the next nested array and bring back those nested values realted to the first array level?
For example, my result must be for each property record:



Propiedades.Id



Propiedades.Precio.Moneda



Propiedades.Precio.Valor



3. Ones I get all the "propiedades" with their values, do I need to create an array to insert those records in a Model? How do I pass the data to the model? My Models will have the structure as the array recevied from the API with the corresponding child entities for "propiedades"




Thanks in advance!
Regards










share|improve this question
























  • Can you attach a full json example so I can work with it in order to help you? I'm interested by the content of the $body variable.

    – Mathieu Bour
    Mar 7 at 2:09











  • Sure, I havee uploaded the requested variable contento in : Link The attached file is the same output as the first screenshot I pasted in the post. Thanks for you help @MathieuBour

    – Belisario Peró
    Mar 7 at 2:39
















0















I need to loop in a mulitidemnsional array being consumed in an outbound API. After consuming the API in a controller, I need to insert the looped records in a Model.



So, the response recieved from the external API is the following:



enter image description here



So, what Im doing in my controller function is the following:



public function index()


$client = new GuzzleHttpClient();
$response = $client->request('GET', 'http://api', [
'headers' => [
'x-authtoken' => '0275d',
'cache-control' => 'no-cache'],
'decode_content' => false
]);

//get body content
$body = $response->getBody()->getContents();
$data = json_decode($body, true);

foreach ( $data['content']['Propiedades'] as $propiedades )

$id = Arr::get($propiedades, 'Id');
$Moneda = Arr::get($propiedades, 'Precio.Moneda');
$Precio = Arr::get($propiedades, 'Precio.Valor')





The problem is that im looping just one instance of "propiedades" array.



enter image description here



1. How can I loop all "propiedades" array and retrieve key values from it?



2. How can access each "propiedades" array to the next nested array and bring back those nested values realted to the first array level?
For example, my result must be for each property record:



Propiedades.Id



Propiedades.Precio.Moneda



Propiedades.Precio.Valor



3. Ones I get all the "propiedades" with their values, do I need to create an array to insert those records in a Model? How do I pass the data to the model? My Models will have the structure as the array recevied from the API with the corresponding child entities for "propiedades"




Thanks in advance!
Regards










share|improve this question
























  • Can you attach a full json example so I can work with it in order to help you? I'm interested by the content of the $body variable.

    – Mathieu Bour
    Mar 7 at 2:09











  • Sure, I havee uploaded the requested variable contento in : Link The attached file is the same output as the first screenshot I pasted in the post. Thanks for you help @MathieuBour

    – Belisario Peró
    Mar 7 at 2:39














0












0








0








I need to loop in a mulitidemnsional array being consumed in an outbound API. After consuming the API in a controller, I need to insert the looped records in a Model.



So, the response recieved from the external API is the following:



enter image description here



So, what Im doing in my controller function is the following:



public function index()


$client = new GuzzleHttpClient();
$response = $client->request('GET', 'http://api', [
'headers' => [
'x-authtoken' => '0275d',
'cache-control' => 'no-cache'],
'decode_content' => false
]);

//get body content
$body = $response->getBody()->getContents();
$data = json_decode($body, true);

foreach ( $data['content']['Propiedades'] as $propiedades )

$id = Arr::get($propiedades, 'Id');
$Moneda = Arr::get($propiedades, 'Precio.Moneda');
$Precio = Arr::get($propiedades, 'Precio.Valor')





The problem is that im looping just one instance of "propiedades" array.



enter image description here



1. How can I loop all "propiedades" array and retrieve key values from it?



2. How can access each "propiedades" array to the next nested array and bring back those nested values realted to the first array level?
For example, my result must be for each property record:



Propiedades.Id



Propiedades.Precio.Moneda



Propiedades.Precio.Valor



3. Ones I get all the "propiedades" with their values, do I need to create an array to insert those records in a Model? How do I pass the data to the model? My Models will have the structure as the array recevied from the API with the corresponding child entities for "propiedades"




Thanks in advance!
Regards










share|improve this question
















I need to loop in a mulitidemnsional array being consumed in an outbound API. After consuming the API in a controller, I need to insert the looped records in a Model.



So, the response recieved from the external API is the following:



enter image description here



So, what Im doing in my controller function is the following:



public function index()


$client = new GuzzleHttpClient();
$response = $client->request('GET', 'http://api', [
'headers' => [
'x-authtoken' => '0275d',
'cache-control' => 'no-cache'],
'decode_content' => false
]);

//get body content
$body = $response->getBody()->getContents();
$data = json_decode($body, true);

foreach ( $data['content']['Propiedades'] as $propiedades )

$id = Arr::get($propiedades, 'Id');
$Moneda = Arr::get($propiedades, 'Precio.Moneda');
$Precio = Arr::get($propiedades, 'Precio.Valor')





The problem is that im looping just one instance of "propiedades" array.



enter image description here



1. How can I loop all "propiedades" array and retrieve key values from it?



2. How can access each "propiedades" array to the next nested array and bring back those nested values realted to the first array level?
For example, my result must be for each property record:



Propiedades.Id



Propiedades.Precio.Moneda



Propiedades.Precio.Valor



3. Ones I get all the "propiedades" with their values, do I need to create an array to insert those records in a Model? How do I pass the data to the model? My Models will have the structure as the array recevied from the API with the corresponding child entities for "propiedades"




Thanks in advance!
Regards







laravel laravel-5 laravel-5.2 laravel-5.1






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 2:04







Belisario Peró

















asked Mar 7 at 0:55









Belisario PeróBelisario Peró

175




175












  • Can you attach a full json example so I can work with it in order to help you? I'm interested by the content of the $body variable.

    – Mathieu Bour
    Mar 7 at 2:09











  • Sure, I havee uploaded the requested variable contento in : Link The attached file is the same output as the first screenshot I pasted in the post. Thanks for you help @MathieuBour

    – Belisario Peró
    Mar 7 at 2:39


















  • Can you attach a full json example so I can work with it in order to help you? I'm interested by the content of the $body variable.

    – Mathieu Bour
    Mar 7 at 2:09











  • Sure, I havee uploaded the requested variable contento in : Link The attached file is the same output as the first screenshot I pasted in the post. Thanks for you help @MathieuBour

    – Belisario Peró
    Mar 7 at 2:39

















Can you attach a full json example so I can work with it in order to help you? I'm interested by the content of the $body variable.

– Mathieu Bour
Mar 7 at 2:09





Can you attach a full json example so I can work with it in order to help you? I'm interested by the content of the $body variable.

– Mathieu Bour
Mar 7 at 2:09













Sure, I havee uploaded the requested variable contento in : Link The attached file is the same output as the first screenshot I pasted in the post. Thanks for you help @MathieuBour

– Belisario Peró
Mar 7 at 2:39






Sure, I havee uploaded the requested variable contento in : Link The attached file is the same output as the first screenshot I pasted in the post. Thanks for you help @MathieuBour

– Belisario Peró
Mar 7 at 2:39













1 Answer
1






active

oldest

votes


















0














Alright i saved whole json into file and then decoded it and printed it all out, i see no complexity in this, it is all looping out as you wanted i checked in local and in my personal production server, data is looping out as you wanted,



Now if you're still having problem specifically in looping then you need to debug more like Is json decoded properly ? something like that. That's my last try for this question specifically looping part, if there is any other issue apart from looping problem then please let me know. :)



 Route::get('/test',function()
$content = json_decode(File::get(public_path().'/custom.txt'),true);
// Actual Content
//dump($content);

// First and Best Approach
foreach ($content['content']['Propiedades'] as $key)
dump($key['Id']);
dump($key['Titulo']);
dump($key['Descripcion']);
dump($key['Precio']);
dump($key['Operacion']);
dump($key['EstadoPublicacion']);
dump($key['Ubicacion']);
dump($key['UbicacionCadena']);
dump($key['TipoPropiedad']);
dump($key['Direccion']);
dump($key['RoundDireccion']);
dump($key['Calle']);
dump($key['Numero']);
dump($key['Latitud']);
dump($key['Longitud']);
dump($key['ImagenPrincipal']);
dump($key['SuperficieTotal']);
dump($key['Dormitorios']);
dump($key['Banios']);
dump($key['CantidadAmbientes']);
dump($key['AtributosDestacadosListado']);
dump($key['Usuario']);
dump($key['IdUbicacion']);
dump($key['Imagenes']);
dump($key['Sucursal']);
dump($key['FechaCreacion']);
dump($key['FechaModificacion']);
dump($key['PublicaPrecio']);
dump($key['PathFicha']);


// Second and Long Approach

// foreach ($content as $key => $value)
// if($key === 'status')
// //dump($value);
// elseif($key === 'content')
// //dump($value);
// foreach ($value as $key1 => $value1)
// if($key1 === 'cantidadPropiedades')
// //dump($value1);
// elseif($key1 === 'cantidadPropiedades')
// //dump($value1);
// elseif($key1 === 'Propiedades')
// //dump($value1);
// foreach ($value1 as $key2 => $value2)
// //dump($value2);
// dump($value2['Id']);
// dump($value2['Titulo']);
// dump($value2['Descripcion']);
// dump($value2['Precio']);
// dump($value2['Operacion']);
// dump($value2['EstadoPublicacion']);
// dump($value2['Ubicacion']);
// dump($value2['UbicacionCadena']);
// dump($value2['TipoPropiedad']);
// dump($value2['Direccion']);
// dump($value2['RoundDireccion']);
// dump($value2['Calle']);
// dump($value2['Numero']);
// dump($value2['Latitud']);
// dump($value2['Longitud']);
// dump($value2['ImagenPrincipal']);
// dump($value2['SuperficieTotal']);
// dump($value2['Dormitorios']);
// dump($value2['Banios']);
// dump($value2['CantidadAmbientes']);
// dump($value2['AtributosDestacadosListado']);
// dump($value2['Usuario']);
// dump($value2['IdUbicacion']);
// dump($value2['Imagenes']);
// dump($value2['Sucursal']);
// dump($value2['FechaCreacion']);
// dump($value2['FechaModificacion']);
// dump($value2['PublicaPrecio']);
// dump($value2['PathFicha']);
//
// elseif($key1 === 'FiltrosAplicados')
// //dump($value1);
// elseif($key1 === 'FiltrosDisponibles')
// //dump($value1);
// elseif($key1 === 'OrdenamientosAplicados')
// //dump($value1);
// elseif($key1 === 'OrdenamientosDisponibles')
// //dump($value1);
// elseif($key1 === 'Paginado')
// //dump($value1);
//
//
// elseif($key === 'errors')
// //dump($value);
//
//
dd("STOP");
)->name('test');


I hope this Helps.






share|improve this answer

























  • Thanks @ViperTecPro ! I understood your approach and that works for part of my issue.The other part is that with your code and mine, I just access 1 element of the 1 level array called "Propiedades", it doesn't loop to all the elementsin that array. Also I need to loop child arrays from "propiedades" if they exists to bring values as I mentioned in my first post. Regards

    – Belisario Peró
    Mar 7 at 11:30












  • i don't understand why is it showing one, i tested with small piece of code with same array you've mentioned, well i updated code,Also please try nested foreach to work with complex array structure, i'm little short on time i will be back soon.

    – ViperTecPro
    Mar 7 at 11:54











  • I'm Back, please give it a try my updated code and if there is any issue let me know.

    – ViperTecPro
    Mar 7 at 16:54











  • Thanks @ViperTecPro, let me test ypu code with mine and I will update. Regards

    – Belisario Peró
    Mar 7 at 17:36











  • That's great i will be waiting

    – ViperTecPro
    Mar 7 at 17:37










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55034454%2floop-multidimensional-array-in-controller%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Alright i saved whole json into file and then decoded it and printed it all out, i see no complexity in this, it is all looping out as you wanted i checked in local and in my personal production server, data is looping out as you wanted,



Now if you're still having problem specifically in looping then you need to debug more like Is json decoded properly ? something like that. That's my last try for this question specifically looping part, if there is any other issue apart from looping problem then please let me know. :)



 Route::get('/test',function()
$content = json_decode(File::get(public_path().'/custom.txt'),true);
// Actual Content
//dump($content);

// First and Best Approach
foreach ($content['content']['Propiedades'] as $key)
dump($key['Id']);
dump($key['Titulo']);
dump($key['Descripcion']);
dump($key['Precio']);
dump($key['Operacion']);
dump($key['EstadoPublicacion']);
dump($key['Ubicacion']);
dump($key['UbicacionCadena']);
dump($key['TipoPropiedad']);
dump($key['Direccion']);
dump($key['RoundDireccion']);
dump($key['Calle']);
dump($key['Numero']);
dump($key['Latitud']);
dump($key['Longitud']);
dump($key['ImagenPrincipal']);
dump($key['SuperficieTotal']);
dump($key['Dormitorios']);
dump($key['Banios']);
dump($key['CantidadAmbientes']);
dump($key['AtributosDestacadosListado']);
dump($key['Usuario']);
dump($key['IdUbicacion']);
dump($key['Imagenes']);
dump($key['Sucursal']);
dump($key['FechaCreacion']);
dump($key['FechaModificacion']);
dump($key['PublicaPrecio']);
dump($key['PathFicha']);


// Second and Long Approach

// foreach ($content as $key => $value)
// if($key === 'status')
// //dump($value);
// elseif($key === 'content')
// //dump($value);
// foreach ($value as $key1 => $value1)
// if($key1 === 'cantidadPropiedades')
// //dump($value1);
// elseif($key1 === 'cantidadPropiedades')
// //dump($value1);
// elseif($key1 === 'Propiedades')
// //dump($value1);
// foreach ($value1 as $key2 => $value2)
// //dump($value2);
// dump($value2['Id']);
// dump($value2['Titulo']);
// dump($value2['Descripcion']);
// dump($value2['Precio']);
// dump($value2['Operacion']);
// dump($value2['EstadoPublicacion']);
// dump($value2['Ubicacion']);
// dump($value2['UbicacionCadena']);
// dump($value2['TipoPropiedad']);
// dump($value2['Direccion']);
// dump($value2['RoundDireccion']);
// dump($value2['Calle']);
// dump($value2['Numero']);
// dump($value2['Latitud']);
// dump($value2['Longitud']);
// dump($value2['ImagenPrincipal']);
// dump($value2['SuperficieTotal']);
// dump($value2['Dormitorios']);
// dump($value2['Banios']);
// dump($value2['CantidadAmbientes']);
// dump($value2['AtributosDestacadosListado']);
// dump($value2['Usuario']);
// dump($value2['IdUbicacion']);
// dump($value2['Imagenes']);
// dump($value2['Sucursal']);
// dump($value2['FechaCreacion']);
// dump($value2['FechaModificacion']);
// dump($value2['PublicaPrecio']);
// dump($value2['PathFicha']);
//
// elseif($key1 === 'FiltrosAplicados')
// //dump($value1);
// elseif($key1 === 'FiltrosDisponibles')
// //dump($value1);
// elseif($key1 === 'OrdenamientosAplicados')
// //dump($value1);
// elseif($key1 === 'OrdenamientosDisponibles')
// //dump($value1);
// elseif($key1 === 'Paginado')
// //dump($value1);
//
//
// elseif($key === 'errors')
// //dump($value);
//
//
dd("STOP");
)->name('test');


I hope this Helps.






share|improve this answer

























  • Thanks @ViperTecPro ! I understood your approach and that works for part of my issue.The other part is that with your code and mine, I just access 1 element of the 1 level array called "Propiedades", it doesn't loop to all the elementsin that array. Also I need to loop child arrays from "propiedades" if they exists to bring values as I mentioned in my first post. Regards

    – Belisario Peró
    Mar 7 at 11:30












  • i don't understand why is it showing one, i tested with small piece of code with same array you've mentioned, well i updated code,Also please try nested foreach to work with complex array structure, i'm little short on time i will be back soon.

    – ViperTecPro
    Mar 7 at 11:54











  • I'm Back, please give it a try my updated code and if there is any issue let me know.

    – ViperTecPro
    Mar 7 at 16:54











  • Thanks @ViperTecPro, let me test ypu code with mine and I will update. Regards

    – Belisario Peró
    Mar 7 at 17:36











  • That's great i will be waiting

    – ViperTecPro
    Mar 7 at 17:37















0














Alright i saved whole json into file and then decoded it and printed it all out, i see no complexity in this, it is all looping out as you wanted i checked in local and in my personal production server, data is looping out as you wanted,



Now if you're still having problem specifically in looping then you need to debug more like Is json decoded properly ? something like that. That's my last try for this question specifically looping part, if there is any other issue apart from looping problem then please let me know. :)



 Route::get('/test',function()
$content = json_decode(File::get(public_path().'/custom.txt'),true);
// Actual Content
//dump($content);

// First and Best Approach
foreach ($content['content']['Propiedades'] as $key)
dump($key['Id']);
dump($key['Titulo']);
dump($key['Descripcion']);
dump($key['Precio']);
dump($key['Operacion']);
dump($key['EstadoPublicacion']);
dump($key['Ubicacion']);
dump($key['UbicacionCadena']);
dump($key['TipoPropiedad']);
dump($key['Direccion']);
dump($key['RoundDireccion']);
dump($key['Calle']);
dump($key['Numero']);
dump($key['Latitud']);
dump($key['Longitud']);
dump($key['ImagenPrincipal']);
dump($key['SuperficieTotal']);
dump($key['Dormitorios']);
dump($key['Banios']);
dump($key['CantidadAmbientes']);
dump($key['AtributosDestacadosListado']);
dump($key['Usuario']);
dump($key['IdUbicacion']);
dump($key['Imagenes']);
dump($key['Sucursal']);
dump($key['FechaCreacion']);
dump($key['FechaModificacion']);
dump($key['PublicaPrecio']);
dump($key['PathFicha']);


// Second and Long Approach

// foreach ($content as $key => $value)
// if($key === 'status')
// //dump($value);
// elseif($key === 'content')
// //dump($value);
// foreach ($value as $key1 => $value1)
// if($key1 === 'cantidadPropiedades')
// //dump($value1);
// elseif($key1 === 'cantidadPropiedades')
// //dump($value1);
// elseif($key1 === 'Propiedades')
// //dump($value1);
// foreach ($value1 as $key2 => $value2)
// //dump($value2);
// dump($value2['Id']);
// dump($value2['Titulo']);
// dump($value2['Descripcion']);
// dump($value2['Precio']);
// dump($value2['Operacion']);
// dump($value2['EstadoPublicacion']);
// dump($value2['Ubicacion']);
// dump($value2['UbicacionCadena']);
// dump($value2['TipoPropiedad']);
// dump($value2['Direccion']);
// dump($value2['RoundDireccion']);
// dump($value2['Calle']);
// dump($value2['Numero']);
// dump($value2['Latitud']);
// dump($value2['Longitud']);
// dump($value2['ImagenPrincipal']);
// dump($value2['SuperficieTotal']);
// dump($value2['Dormitorios']);
// dump($value2['Banios']);
// dump($value2['CantidadAmbientes']);
// dump($value2['AtributosDestacadosListado']);
// dump($value2['Usuario']);
// dump($value2['IdUbicacion']);
// dump($value2['Imagenes']);
// dump($value2['Sucursal']);
// dump($value2['FechaCreacion']);
// dump($value2['FechaModificacion']);
// dump($value2['PublicaPrecio']);
// dump($value2['PathFicha']);
//
// elseif($key1 === 'FiltrosAplicados')
// //dump($value1);
// elseif($key1 === 'FiltrosDisponibles')
// //dump($value1);
// elseif($key1 === 'OrdenamientosAplicados')
// //dump($value1);
// elseif($key1 === 'OrdenamientosDisponibles')
// //dump($value1);
// elseif($key1 === 'Paginado')
// //dump($value1);
//
//
// elseif($key === 'errors')
// //dump($value);
//
//
dd("STOP");
)->name('test');


I hope this Helps.






share|improve this answer

























  • Thanks @ViperTecPro ! I understood your approach and that works for part of my issue.The other part is that with your code and mine, I just access 1 element of the 1 level array called "Propiedades", it doesn't loop to all the elementsin that array. Also I need to loop child arrays from "propiedades" if they exists to bring values as I mentioned in my first post. Regards

    – Belisario Peró
    Mar 7 at 11:30












  • i don't understand why is it showing one, i tested with small piece of code with same array you've mentioned, well i updated code,Also please try nested foreach to work with complex array structure, i'm little short on time i will be back soon.

    – ViperTecPro
    Mar 7 at 11:54











  • I'm Back, please give it a try my updated code and if there is any issue let me know.

    – ViperTecPro
    Mar 7 at 16:54











  • Thanks @ViperTecPro, let me test ypu code with mine and I will update. Regards

    – Belisario Peró
    Mar 7 at 17:36











  • That's great i will be waiting

    – ViperTecPro
    Mar 7 at 17:37













0












0








0







Alright i saved whole json into file and then decoded it and printed it all out, i see no complexity in this, it is all looping out as you wanted i checked in local and in my personal production server, data is looping out as you wanted,



Now if you're still having problem specifically in looping then you need to debug more like Is json decoded properly ? something like that. That's my last try for this question specifically looping part, if there is any other issue apart from looping problem then please let me know. :)



 Route::get('/test',function()
$content = json_decode(File::get(public_path().'/custom.txt'),true);
// Actual Content
//dump($content);

// First and Best Approach
foreach ($content['content']['Propiedades'] as $key)
dump($key['Id']);
dump($key['Titulo']);
dump($key['Descripcion']);
dump($key['Precio']);
dump($key['Operacion']);
dump($key['EstadoPublicacion']);
dump($key['Ubicacion']);
dump($key['UbicacionCadena']);
dump($key['TipoPropiedad']);
dump($key['Direccion']);
dump($key['RoundDireccion']);
dump($key['Calle']);
dump($key['Numero']);
dump($key['Latitud']);
dump($key['Longitud']);
dump($key['ImagenPrincipal']);
dump($key['SuperficieTotal']);
dump($key['Dormitorios']);
dump($key['Banios']);
dump($key['CantidadAmbientes']);
dump($key['AtributosDestacadosListado']);
dump($key['Usuario']);
dump($key['IdUbicacion']);
dump($key['Imagenes']);
dump($key['Sucursal']);
dump($key['FechaCreacion']);
dump($key['FechaModificacion']);
dump($key['PublicaPrecio']);
dump($key['PathFicha']);


// Second and Long Approach

// foreach ($content as $key => $value)
// if($key === 'status')
// //dump($value);
// elseif($key === 'content')
// //dump($value);
// foreach ($value as $key1 => $value1)
// if($key1 === 'cantidadPropiedades')
// //dump($value1);
// elseif($key1 === 'cantidadPropiedades')
// //dump($value1);
// elseif($key1 === 'Propiedades')
// //dump($value1);
// foreach ($value1 as $key2 => $value2)
// //dump($value2);
// dump($value2['Id']);
// dump($value2['Titulo']);
// dump($value2['Descripcion']);
// dump($value2['Precio']);
// dump($value2['Operacion']);
// dump($value2['EstadoPublicacion']);
// dump($value2['Ubicacion']);
// dump($value2['UbicacionCadena']);
// dump($value2['TipoPropiedad']);
// dump($value2['Direccion']);
// dump($value2['RoundDireccion']);
// dump($value2['Calle']);
// dump($value2['Numero']);
// dump($value2['Latitud']);
// dump($value2['Longitud']);
// dump($value2['ImagenPrincipal']);
// dump($value2['SuperficieTotal']);
// dump($value2['Dormitorios']);
// dump($value2['Banios']);
// dump($value2['CantidadAmbientes']);
// dump($value2['AtributosDestacadosListado']);
// dump($value2['Usuario']);
// dump($value2['IdUbicacion']);
// dump($value2['Imagenes']);
// dump($value2['Sucursal']);
// dump($value2['FechaCreacion']);
// dump($value2['FechaModificacion']);
// dump($value2['PublicaPrecio']);
// dump($value2['PathFicha']);
//
// elseif($key1 === 'FiltrosAplicados')
// //dump($value1);
// elseif($key1 === 'FiltrosDisponibles')
// //dump($value1);
// elseif($key1 === 'OrdenamientosAplicados')
// //dump($value1);
// elseif($key1 === 'OrdenamientosDisponibles')
// //dump($value1);
// elseif($key1 === 'Paginado')
// //dump($value1);
//
//
// elseif($key === 'errors')
// //dump($value);
//
//
dd("STOP");
)->name('test');


I hope this Helps.






share|improve this answer















Alright i saved whole json into file and then decoded it and printed it all out, i see no complexity in this, it is all looping out as you wanted i checked in local and in my personal production server, data is looping out as you wanted,



Now if you're still having problem specifically in looping then you need to debug more like Is json decoded properly ? something like that. That's my last try for this question specifically looping part, if there is any other issue apart from looping problem then please let me know. :)



 Route::get('/test',function()
$content = json_decode(File::get(public_path().'/custom.txt'),true);
// Actual Content
//dump($content);

// First and Best Approach
foreach ($content['content']['Propiedades'] as $key)
dump($key['Id']);
dump($key['Titulo']);
dump($key['Descripcion']);
dump($key['Precio']);
dump($key['Operacion']);
dump($key['EstadoPublicacion']);
dump($key['Ubicacion']);
dump($key['UbicacionCadena']);
dump($key['TipoPropiedad']);
dump($key['Direccion']);
dump($key['RoundDireccion']);
dump($key['Calle']);
dump($key['Numero']);
dump($key['Latitud']);
dump($key['Longitud']);
dump($key['ImagenPrincipal']);
dump($key['SuperficieTotal']);
dump($key['Dormitorios']);
dump($key['Banios']);
dump($key['CantidadAmbientes']);
dump($key['AtributosDestacadosListado']);
dump($key['Usuario']);
dump($key['IdUbicacion']);
dump($key['Imagenes']);
dump($key['Sucursal']);
dump($key['FechaCreacion']);
dump($key['FechaModificacion']);
dump($key['PublicaPrecio']);
dump($key['PathFicha']);


// Second and Long Approach

// foreach ($content as $key => $value)
// if($key === 'status')
// //dump($value);
// elseif($key === 'content')
// //dump($value);
// foreach ($value as $key1 => $value1)
// if($key1 === 'cantidadPropiedades')
// //dump($value1);
// elseif($key1 === 'cantidadPropiedades')
// //dump($value1);
// elseif($key1 === 'Propiedades')
// //dump($value1);
// foreach ($value1 as $key2 => $value2)
// //dump($value2);
// dump($value2['Id']);
// dump($value2['Titulo']);
// dump($value2['Descripcion']);
// dump($value2['Precio']);
// dump($value2['Operacion']);
// dump($value2['EstadoPublicacion']);
// dump($value2['Ubicacion']);
// dump($value2['UbicacionCadena']);
// dump($value2['TipoPropiedad']);
// dump($value2['Direccion']);
// dump($value2['RoundDireccion']);
// dump($value2['Calle']);
// dump($value2['Numero']);
// dump($value2['Latitud']);
// dump($value2['Longitud']);
// dump($value2['ImagenPrincipal']);
// dump($value2['SuperficieTotal']);
// dump($value2['Dormitorios']);
// dump($value2['Banios']);
// dump($value2['CantidadAmbientes']);
// dump($value2['AtributosDestacadosListado']);
// dump($value2['Usuario']);
// dump($value2['IdUbicacion']);
// dump($value2['Imagenes']);
// dump($value2['Sucursal']);
// dump($value2['FechaCreacion']);
// dump($value2['FechaModificacion']);
// dump($value2['PublicaPrecio']);
// dump($value2['PathFicha']);
//
// elseif($key1 === 'FiltrosAplicados')
// //dump($value1);
// elseif($key1 === 'FiltrosDisponibles')
// //dump($value1);
// elseif($key1 === 'OrdenamientosAplicados')
// //dump($value1);
// elseif($key1 === 'OrdenamientosDisponibles')
// //dump($value1);
// elseif($key1 === 'Paginado')
// //dump($value1);
//
//
// elseif($key === 'errors')
// //dump($value);
//
//
dd("STOP");
)->name('test');


I hope this Helps.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 8 at 16:37

























answered Mar 7 at 5:37









ViperTecProViperTecPro

583416




583416












  • Thanks @ViperTecPro ! I understood your approach and that works for part of my issue.The other part is that with your code and mine, I just access 1 element of the 1 level array called "Propiedades", it doesn't loop to all the elementsin that array. Also I need to loop child arrays from "propiedades" if they exists to bring values as I mentioned in my first post. Regards

    – Belisario Peró
    Mar 7 at 11:30












  • i don't understand why is it showing one, i tested with small piece of code with same array you've mentioned, well i updated code,Also please try nested foreach to work with complex array structure, i'm little short on time i will be back soon.

    – ViperTecPro
    Mar 7 at 11:54











  • I'm Back, please give it a try my updated code and if there is any issue let me know.

    – ViperTecPro
    Mar 7 at 16:54











  • Thanks @ViperTecPro, let me test ypu code with mine and I will update. Regards

    – Belisario Peró
    Mar 7 at 17:36











  • That's great i will be waiting

    – ViperTecPro
    Mar 7 at 17:37

















  • Thanks @ViperTecPro ! I understood your approach and that works for part of my issue.The other part is that with your code and mine, I just access 1 element of the 1 level array called "Propiedades", it doesn't loop to all the elementsin that array. Also I need to loop child arrays from "propiedades" if they exists to bring values as I mentioned in my first post. Regards

    – Belisario Peró
    Mar 7 at 11:30












  • i don't understand why is it showing one, i tested with small piece of code with same array you've mentioned, well i updated code,Also please try nested foreach to work with complex array structure, i'm little short on time i will be back soon.

    – ViperTecPro
    Mar 7 at 11:54











  • I'm Back, please give it a try my updated code and if there is any issue let me know.

    – ViperTecPro
    Mar 7 at 16:54











  • Thanks @ViperTecPro, let me test ypu code with mine and I will update. Regards

    – Belisario Peró
    Mar 7 at 17:36











  • That's great i will be waiting

    – ViperTecPro
    Mar 7 at 17:37
















Thanks @ViperTecPro ! I understood your approach and that works for part of my issue.The other part is that with your code and mine, I just access 1 element of the 1 level array called "Propiedades", it doesn't loop to all the elementsin that array. Also I need to loop child arrays from "propiedades" if they exists to bring values as I mentioned in my first post. Regards

– Belisario Peró
Mar 7 at 11:30






Thanks @ViperTecPro ! I understood your approach and that works for part of my issue.The other part is that with your code and mine, I just access 1 element of the 1 level array called "Propiedades", it doesn't loop to all the elementsin that array. Also I need to loop child arrays from "propiedades" if they exists to bring values as I mentioned in my first post. Regards

– Belisario Peró
Mar 7 at 11:30














i don't understand why is it showing one, i tested with small piece of code with same array you've mentioned, well i updated code,Also please try nested foreach to work with complex array structure, i'm little short on time i will be back soon.

– ViperTecPro
Mar 7 at 11:54





i don't understand why is it showing one, i tested with small piece of code with same array you've mentioned, well i updated code,Also please try nested foreach to work with complex array structure, i'm little short on time i will be back soon.

– ViperTecPro
Mar 7 at 11:54













I'm Back, please give it a try my updated code and if there is any issue let me know.

– ViperTecPro
Mar 7 at 16:54





I'm Back, please give it a try my updated code and if there is any issue let me know.

– ViperTecPro
Mar 7 at 16:54













Thanks @ViperTecPro, let me test ypu code with mine and I will update. Regards

– Belisario Peró
Mar 7 at 17:36





Thanks @ViperTecPro, let me test ypu code with mine and I will update. Regards

– Belisario Peró
Mar 7 at 17:36













That's great i will be waiting

– ViperTecPro
Mar 7 at 17:37





That's great i will be waiting

– ViperTecPro
Mar 7 at 17:37



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55034454%2floop-multidimensional-array-in-controller%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко