我在php中有一系列傅立叶变换值,如下所示。
[8974,398.22605659378,340.40931712583,224.61805748557,224.21476160103,531.02102311671,348.09311299013,74.373164045484,440.15451832283,379.54095616825,801.05398080895,184.15175862698,539.59590498835,114.82864261836,595.84662567888,488.12623039438,370,488.12623039438,595.84662567888,114.82864261836,539.59590498835,184.15175862698,801.05398080895,379.54095616825,440.15451832283,74.373164045484,348.09311299013,531.02102311671,224.21476160103,224.61805748557,340.40931712582,398.22605659378]
如何在php语言中实际忽略/删除本案例“8974”中的第一个值?
答案 0 :(得分:0)
通过跳过第一个元素来创建第一个临时数组:
foreach (array_slice($arr, 1) as $xyz) {
/// ...
}
或者,不创建临时数组:
reset($arr); next($arr); // reset and skip first element
while (list($key, $value) = each($arr)) {
echo $value;
}
通过关闭第一项来修改数组:
array_shift($arr);
// do whatever you want
答案 1 :(得分:0)
您可以使用array_shift();
<强>像强>
$array=array(8974,398.22605659378,340.40931712583,224.61805748557,224.21476160103,531.02102311671,348.09311299013,74.373164045484,440.15451832283,379.54095616825,801.05398080895,184.15175862698,539.59590498835,114.82864261836,595.84662567888,488.12623039438,370,488.12623039438,595.84662567888,114.82864261836,539.59590498835,184.15175862698,801.05398080895,379.54095616825,440.15451832283,74.373164045484,348.09311299013,531.02102311671,224.21476160103,224.61805748557,340.40931712582,398.22605659378);
array_shift($array);
print_r($array);
答案 2 :(得分:0)
您可以使用array_shift
即:
$myArray = array(8974,398.22605659378,340.40931712583,224.61805748557,224.21476160103,531.02102311671,348.09311299013,74.373164045484,440.15451832283,379.54095616825,801.05398080895,184.15175862698,539.59590498835,114.82864261836,595.84662567888,488.12623039438,370,488.12623039438,595.84662567888,114.82864261836,539.59590498835,184.15175862698,801.05398080895,379.54095616825,440.15451832283,74.373164045484,348.09311299013,531.02102311671,224.21476160103,224.61805748557,340.40931712582,398.22605659378);
array_shift($myArray)
答案 3 :(得分:0)
您可以轻松unset
第一个元素删除它:
unset($array[0]);