+ 1
Problem regarding arrays PHP
<?php $people = array( 'online'=>array('David', 'Amy'), 'offline'=>array('John', 'Rob', 'Jack'), 'away'=>array('Arthur', 'is'), 'busy'=>('Godlike') ); echo $people['online'][0]; echo "<br />"; echo $people['away'][1]; echo "<br />"; echo $people['busy'][0]; ?> I know that i did not put array after busy but someone can explains me why it is showing me just G ? ( the first letter of godlike ).
1 Respuesta
0
A string is similar to an array in that you can use square brackets to get individual characters.
$people["busy"] gives you the string "Godlike" (not the array ["Godlike"] as you pointed out), so $people["busy"][0] gives you the first element of "Godlike" which is 'G'!