Illegal offset type error when => value is omitted
- by thomas
Line 3 of the code below fails if I omit the => $v portion. I get the following error:
Warning: Illegal offset type in /home/site/page.php on line 404
When the [$k] in line 5 is changed to ['$k'], i receive the following error.
Notice: Undefined index: $k in /home/site/page.php on line 404
When it is like below with the the full $k => $v everything works though. I don't even use $v. Why do I need it in the foreach loop to make it work then?
<? if ( $arr[ 'status'][ 'chain'] ) {
foreach ( $arr[ 'status'][ 'chain'] as $k => $v) { ?>
<tr>
<td class="line_item_data status_td">
<?= $ arr[ 'status'][ 'chain'][$k][ 'message'] ?>
</td>
<td align="center">
<img src="images/green_check.gif" width="20" />
</td>
</tr>
<? }
} ?>
I did see this answer, but don't know that it really applies. Thanks so much!