Nested foreach()

前端 未结 4 2039
面向向阳花
面向向阳花 2021-01-08 00:56

I have the following array:

Array ( 
  [1] => Array ( 
    [spubid] => A00319 
    [sentered_by] => pubs_batchadd.php
    [sarticle] => Lateral m         


        
4条回答
  •  长发绾君心
    2021-01-08 01:35

    Why don't you do

    foreach($apubs as $apub) {
      $sauthors = '';
      $stitle = $apub['sarticle'];
      foreach($apub['authors'] as $author) {
        $sauthors .= $author['slast'].", ".$author['sfirst']."; ";
      }
    
      echo "$sauthors
    \n$stitle
    \n"; }

提交回复
热议问题