<?php
$dsts = array (
array (
"starttime" => "2013-01-15",
"duration" => "120",
"repeat" => 50,
"noticefile" => "mmmmm"
),
array (
"starttime" => "2013-01-16",
"duration" => "130",
"repeat" => 60,
"noticefile" => "ttttt"
),
array (
"starttime" => "2013-01-17",
"duration" => "140",
"repeat" => 70,
"noticefile" => "eeeee"
)
);
foreach ( $dsts as &$dst ) {
$dst ["noticefile"] = "-";
print_r ( $dst );
}
unset ( $dst );
print_r ( $dsts );
foreach ( $dsts as $dst ) {
$dst ["noticefile"] = "+";
print_r ( $dst );
}
print_r ( $dsts );
?>
输出结果:
Array | |
( | |
[starttime] => 2013-01-15 | |
[duration] => 120 | |
[repeat] => 50 | |
[noticefile] => - | |
) | |
Array | |
( | |
[starttime] => 2013-01-16 | |
[duration] => 130 | |
[repeat] => 60 | |
[noticefile] => - | |
) | |
Array | |
( | |
[starttime] => 2013-01-17 | |
[duration] => 140 | |
[repeat] => 70 | |
[noticefile] => - | |
) | |
Array | |
( | |
[0] => Array | |
( | |
[starttime] => 2013-01-15 | |
[duration] => 120 | |
[repeat] => 50 | |
[noticefile] => - | |
) | |
[1] => Array | |
( | |
[starttime] => 2013-01-16 | |
[duration] => 130 | |
[repeat] => 60 | |
[noticefile] => - | |
) | |
[2] => Array | |
( | |
[starttime] => 2013-01-17 | |
[duration] => 140 | |
[repeat] => 70 | |
[noticefile] => - | |
) | |
) | |
Array | |
( | |
[starttime] => 2013-01-15 | |
[duration] => 120 | |
[repeat] => 50 | |
[noticefile] => + | |
) | |
Array | |
( | |
[starttime] => 2013-01-16 | |
[duration] => 130 | |
[repeat] => 60 | |
[noticefile] => + | |
) | |
Array | |
( | |
[starttime] => 2013-01-17 | |
[duration] => 140 | |
[repeat] => 70 | |
[noticefile] => + | |
) | |
Array | |
( | |
[0] => Array | |
( | |
[starttime] => 2013-01-15 | |
[duration] => 120 | |
[repeat] => 50 | |
[noticefile] => - | |
) | |
[1] => Array | |
( | |
[starttime] => 2013-01-16 | |
[duration] => 130 | |
[repeat] => 60 | |
[noticefile] => - | |
) | |
[2] => Array | |
( | |
[starttime] => 2013-01-17 | |
[duration] => 140 | |
[repeat] => 70 | |
[noticefile] => - | |
) | |
) | |
如果没有unset就会出现:
Array | |
( | |
[starttime] => 2013-01-15 | |
[duration] => 120 | |
[repeat] => 50 | |
[noticefile] => - | |
) | |
Array | |
( | |
[starttime] => 2013-01-16 | |
[duration] => 130 | |
[repeat] => 60 | |
[noticefile] => - | |
) | |
Array | |
( | |
[starttime] => 2013-01-17 | |
[duration] => 140 | |
[repeat] => 70 | |
[noticefile] => - | |
) | |
Array | |
( | |
[0] => Array | |
( | |
[starttime] => 2013-01-15 | |
[duration] => 120 | |
[repeat] => 50 | |
[noticefile] => - | |
) | |
[1] => Array | |
( | |
[starttime] => 2013-01-16 | |
[duration] => 130 | |
[repeat] => 60 | |
[noticefile] => - | |
) | |
[2] => Array | |
( | |
[starttime] => 2013-01-17 | |
[duration] => 140 | |
[repeat] => 70 | |
[noticefile] => - | |
) | |
) | |
Array | |
( | |
[starttime] => 2013-01-15 | |
[duration] => 120 | |
[repeat] => 50 | |
[noticefile] => + | |
) | |
Array | |
( | |
[starttime] => 2013-01-16 | |
[duration] => 130 | |
[repeat] => 60 | |
[noticefile] => + | |
) | |
Array | |
( | |
[starttime] => 2013-01-16 | |
[duration] => 130 | |
[repeat] => 60 | |
[noticefile] => + | |
) | |
Array | |
( | |
[0] => Array | |
( | |
[starttime] => 2013-01-15 | |
[duration] => 120 | |
[repeat] => 50 | |
[noticefile] => - | |
) | |
[1] => Array | |
( | |
[starttime] => 2013-01-16 | |
[duration] => 130 | |
[repeat] => 60 | |
[noticefile] => - | |
) | |
[2] => Array | |
( | |
[starttime] => 2013-01-16 | |
[duration] => 130 | |
[repeat] => 60 | |
[noticefile] => + | |
) | |
) | |