need to unserialize an array within an array and print it to a table in php -


<?php  $data = 'a:4:{s:4:"name";s:8:"john doe";s:7:"address";a:4:{s:6:"street";s:11:"123 main st";s:4:"city";s:5:"dover";s:5:"state";s:2:"de";s:3:"zip";s:5:"19904";}s:5:"phone";s:12:"555-555-1234";s:5:"email";s:16:"john@example.com";} a:4:{s:4:"name";s:8:"jane doe";s:7:"address";a:4:{s:6:"street";s:11:"123 main st";s:4:"city";s:5:"dover";s:5:"state";s:2:"de";s:3:"zip";s:5:"19904";}s:5:"phone";s:12:"555-555-5678";s:5:"email";s:16:"jane@example.com";} a:4:{s:4:"name";s:15:"jonny appleseed";s:7:"address";a:4:{s:6:"street";s:15:"1 infinite loop";s:4:"city";s:10:"coopertino";s:5:"state";s:2:"ca";s:3:"zip";s:5:"90201";}s:5:"phone";s:12:"555-555-9101";s:5:"email";s:15:"jonny@apple.com";} a:4:{s:4:"name";s:12:"jack sparrow";s:7:"address";a:4:{s:6:"street";s:15:"the black pearl";s:4:"city";s:17:"cut throat island";s:5:"state";s:7:"tortuga";s:3:"zip";s:5:"00001";}s:5:"phone";s:12:"555-555-1213";s:5:"email";s:14:"jack@savvy.com";} a:4:{s:4:"name";s:14:"luke skywalker";s:7:"address";a:4:{s:6:"street";s:15:"17 jedi council";s:4:"city";s:8:"corasant";s:5:"state";s:2:"xx";s:3:"zip";s:5:"99999";}s:5:"phone";s:12:"555-555-1415";s:5:"email";s:17:"luke@theforce.com";}';    $fexplode = explode(php_eol, $data);  foreach ($fexplode $uline) {      ?> <table cellpadding="2" cellspacing="2" align="left"> <table> <?php     foreach (unserialize($uline) $item => $value){  ?>     <tr>     <td><b><?php echo $item . ": ";?></b></td>     <td><?php if ($item == 'address'){                     print "need print address array here";                 }                 else {             echo $value;         }         ?> </td>     </tr>     <br>  <?php } ?>  </table>  <?php } ?> 

this prints arrays in table when gets address portion array within array spits out "array string conversion" if replace 'print "need print address array here"' 'echo $value;'

in case echo $value; if $value array, show notice "array string conversion".

use foreach echo array.

if(is_array($value)):     foreach($value $value_in):        echo $value_in;     endforeach; endif; 

Comments