<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" name="viewport" content="width=device-width"/> <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/> </head> <body> <nav class="navbar navbar-default"> <div class="container-fluid"> <a class="navbar-brand" href="https://sourcecodester.com">Sourcecodester</a> </div> </nav> <div class="col-md-3"></div> <div class="col-md-6 well"> <h3 class="text-primary">PHP - Return Array As A String</h3> <hr style="border-top:1px dotted #ccc;"/> <?php $hero = [ 'Marvel' => ['Captain America', 'Iron Man', 'Incredible Hulk', 'Thor', 'Black Widow'], 'DC' => ['Superman', 'Batman', 'Wonderwoman', 'Flash', 'Aquaman'] ]; ?> <div class="col-md-2"></div> <div class="col-md-8"> </div> <form method="POST" action=""> <center><button name="convert" class="btn btn-primary">Array to String</button></center> </form> <?php }else{ include'string.php'; } ?> </div> </body> </html>
<div class="col-md-6"> <table class="table table-bordered"> <?php foreach($hero as $section => $list){ if($section=="Marvel"){ ?> <tr class="alert-info"> <th><center><?php echo $section?></center></th> </tr> <?php foreach($list as $key => $value){ ?> <tr style="background-color:#fff;"> <td><?php echo $value?></td> </tr> <?php } } } } ?> </table> </div> <div class="col-md-6"> <table class="table table-bordered"> <?php foreach($hero as $section => $list){ if($section=="DC"){ ?> <tr class="alert-info"> <th><center><?php echo $section?></center></th> </tr> <?php foreach($list as $key => $value){ ?> <tr style="background-color:#fff;"> <td><?php echo $value?></td> </tr> <?php } } } } ?> </table> </div> <br /> <center><a class="btn btn-success" href="index.php"><span class="glyphicon glyphicon-refresh"></span> Reset</a></center>