1

I'm trying to access a specific position in the array. My intention of this is to know position to position the following structure.

Array ( 
    [0] => Array ( 
    [id] => 215150311 
    [descripcion] => CHOCOLATE HERSHEYS 
    [status] => 23324 
    [precio] => 2.67 )

    [1] => Array ( 
    [id] => 215156968 
    [descripcion] => HUEVO DE CHOCOLATE 
    [status] => 7296 
    [precio1] => 9.72 
    ) )

I go around with a double forEach but I can not access a specific position such as Product Overview, field 2.

foreach($matriz as $row => $innerArray){
    foreach($innerArray as $innerRow => $value){
     //echo "el key es " .$innerRow . " y el valor es : " . $value. "<br/>";
     //echo "arreglo ".$matriz[$value[1]]; 
     echo "El valor es ".$value."<br/>";
     }
  }

What am I doing wrong?

Thanks for your support.

1 Answer 1

3

Why do you use two foreach? It seems you need only one.

foreach($matriz as $row => $innerArray){
     echo "El valor es ".$innerArray['descripcion']."<br/>";
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.