0

For some reason I really can’t output an array. Can you help please

<?php foreach ( $feature as $b=>$features_collapsee): ?>
    <?php var_dump($features_collapsee) ?>
<?php endforeach; ?>

displays

string(12) "1 GB - 1 €" array(2) {
   [0]=> array(2) { ["features_collapse_title"]=> string(22) "Interneti maht paketis"
         ["features_collapse_description"]=> string(4) "0 GB" }
   [1]=> array(2) { ["features_collapse_title"]=> string(5) "lorem"
                  ["features_collapse_description"]=> string(5) "lorem" } }

i want display

Interneti maht paketis

0 GB


lorem

lorem
2
  • What is the second part of your snippet? Commented May 12, 2020 at 15:04
  • That is array from var_dump . I want display it with echo Commented May 12, 2020 at 15:05

1 Answer 1

1

Try this:

<?php 

 $data = array(
   array(
    "features_title"=>"Internet Eestis",
    "featrues_description"=>"1 GB - 1 €",
    "features_collapse"=>array(
        array(
       "features_collapse_title"=>"Interneti maht paketis",
       "features_collapse_description"=>"0 GB"
       ),

      array(
       "features_collapse_title"=>"lorem",
       "features_collapse_description"=>"lorem"
       )
    )
  )
 );

 foreach ($data[0] as $key=>$value )
 {
  if(is_array($value)){
    foreach($value as $t){
        echo $t['features_collapse_title']."<br>";
        echo $t['features_collapse_description']."<br>";
    }
  }
}
?>
Sign up to request clarification or add additional context in comments.

5 Comments

Warning: Invalid argument supplied for foreach() in it's return warning second foreach
@Kaiserr try it again
It's return only Internet Eestis i want return all
try echo $features_collapsee->features_collapse_title; and features_collapsee->features_collapse_description

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.