// the index will reset
$a
=
array_shift
(
$numbers
);
echo
'a: '.
$a
.'<br />';
print_r(
$numbers
);
// push element to the front of array
// returns the count of array and reset array index
$b
=
array_unshift
(
$numbers
, 'first');
echo
'<br />b: '.
$b
.'<br />';
print_r(
$numbers
);
echo
'<hr />';
echo
'<p>pop & push </p>';
// pop the last element out of array
$c
=
array_pop
(
$numbers
);
print_r(
$numbers
);
echo
'<br />';
// push the element to the last of array
$d
=
array_push
(
$numbers
, 'last');
echo
'd: '.
$d
.'<br />';
print_r(
$numbers
);
更多数组函数参考
3. dates
and
times (时间和日期)
有 3 种方法可以创建一个 unix time(从 1970/1/1 到现在的秒数)
time();
返回当前的时间戳
mktime
(
$hr
,
$min
,
$sec
,
$month
,
$day
,
$year
);
mktime
(6,30,0,5,22,2012) 返回 2012 5/22 6:
30:00
的时间戳
strtotime
(
$string
);
strtotime
("+1 day")
返回明天这个时候的时间戳 更多 'last Monday' 'lasy
Year'
checkdate
(
$month
,
$day
,
$year
);
验证一个日期是否为真
checkdate
(5,32,2012) ? 'true' : 'false';
// return false
得到了时间戳后,我们需要对它进行转化为可读的,如 2012/5/22
我们有 2
种方法
date
(
$format
,
$timestamp
) ;
strftime
(
$format
[,
$timestamp
])
推荐用第 2 种,
strftime
("%Y-%m-%d %H:%M:%S");
// return 2012-05-22 15:46:40