星期一, 10月 04, 2004

[php] array 簡單用法

@製造array
(1)單層
$fruit[0] = 'banana';
$fruit[1] = 'papaya';
$favorites['animal'] = 'turtle';
$favorites['monster'] = 'cookie';
(2)多層
$people = array ('David' => array('shirt' => 'blue',
'car' => 'minivan'),
'Adam' => array('shirt' => 'white',
'car' => 'sedan'));
print count($people) 可算出共有多少個element;
(3) Adding the [] after the variable name times lets PHP know that it is an array, and not a scalar.

沒有留言: