我想从此数据'Shareholders123'
a:1:{i:0;s:15:"Shareholders123";}
<?php foreach(unserialize($model->shareholders) as $shareholder): ?>
<tr>
<td><strong><?php echo $shareholder['shareholders']; ?></strong></td>
<td></td>
<td></td>
</tr>
<?php endforeach; ?>
这只是打印“S”。
答案 0 :(得分:1)
$arr = unserialize('a:1:{i:0;s:15:"Shareholders123";}');
foreach($arr as $str) {
echo $str;
}
或只是简单地说:
$arr = unserialize('a:1:{i:0;s:15:"Shareholders123";}');
echo $arr[0];
答案 1 :(得分:1)
你只想做
<?php foreach(unserialize($model->shareholders) as $shareholder): ?>
...
<strong><?php echo $shareholder; ?></strong>
...
<?php endforeach; ?>
因为您没有处理关联数组,所以您不需要按键访问该值。事实上,你甚至没有一个名为“股东”的钥匙。
unserialize('a:1:{i:0;s:15:"Shareholders123";}')
返回此数组:
Array
(
[0] => Shareholders123
)