0

我已经在 php 中运行了 for 循环,我得到了以下输出...我正在尝试将第一个值存储在其他数组中,第二个值存储在其他数组中...请任何人指导我这样做!

或者我如何存储在二维数组中

大批
(
    [0] => 44
    [1] => 810
)
大批
(
    [0] => 0
    [1] => 280
)
大批
(
    [0] => 73
    [1] => 279
)
大批
(
    [0] => 0
    [1] => 278
)
大批
(
    [0] => 0
    [1] => 277
)
大批
(
    [0] => 0
    [1] => 276
)
大批
(
    [0] => 87
    [1] => 840
)
大批
(
    [0] => 0
    [1] => 275
)
大批
(
    [0] => 0
    [1] => 274
)
大批
(
    [0] => 0
    [1] => 273
)
大批
(
    [0] => 6
    [1] => 271
)
大批
(
    [0] => 0
    [1] => 272
)
大批
(
    [0] => 0
    [1] => 269
)
大批
(
    [0] => 3
    [1] => 267
)
大批
(
    [0] => 0
    [1] => 268
)
大批
(
    [0] => 3
    [1] => 259
)
大批
(
    [0] => 108
    [1] => 124
)
大批
(
    [0] => 82
    [1] => 239
)
大批
(
    [0] => 221
    [1] => 238
)
大批
(
    [0] => 30
    [1] => 160
)
大批
(
    [0] => 3
    [1] => 161
)
大批
(
    [0] => 65
    [1] => 168
)
大批
(
    [0] => 73
    [1] => 169
)
大批
(
    [0] => 0
    [1] => 170
)
大批
(
    [0] => 0
    [1] => 248
)
大批
(
    [0] => 192
    [1] => 226
)
大批
(
    [0] => 209
    [1] => 222
)
大批
(
    [0] => 80
    [1] => 223
)
大批
(
    [0] => 182
    [1] => 273
)
大批
(
    [0] => 79
    [1] => 183
)
大批
(
    [0] => 73
    [1] => 184
)
大批
(
    [0] => 73
    [1] => 185
)
大批
(
    [0] => 6
    [1] => 186
)
大批
(
    [0] => 73
    [1] => 187
)
大批
(
    [0] => 0
    [1] => 188
)
大批
(
    [0] => 48
    [1] => 270
)
大批
(
    [0] => 138
    [1] => 190
)
大批
(
    [0] => 191
    [1] => 370
)
大批
(
    [0] => 152
    [1] => 192
)
大批
(
    [0] => 12
    [1] => 200
)
大批
(
    [0] => 200
    [1] => 210
)
大批
(
    [0] => 0
    [1] => 213
)
大批
(
    [0] => 21
    [1] => 212
)
大批
(
    [0] => 124
    [1] => 214
)
大批
(
    [0] => 0
    [1] => 215
)
大批
(
    [0] => 0
    [1] => 216
)
大批
(
    [0] => 133
    [1] => 217
)
大批
(
    [0] => 6
    [1] => 260
)
大批
(
    [0] => 73
    [1] => 285
)
大批
(
    [0] => 73
    [1] => 284
)
大批
(
    [0] => 0
    [1] => 283
)
大批
(
    [0] => 73
    [1] => 286
)
大批
(
    [0] => 73
    [1] => 287
)
大批
(
    [0] => 0
    [1] => 288
)
大批
(
    [0] => 73
    [1] => 289
)
大批
(
    [0] => 0
    [1] => 290
)
大批
(
    [0] => 76
    [1] => 291
)
大批
(
    [0] => 76
    [1] => 292
)
大批
(
    [0] => 0
    [1] => 293
)
大批
(
    [0] => 0
    [1] => 294
)
大批
(
    [0] => 0
    [1] => 295
)
大批
(
    [0] => 0
    [1] => 296
)
大批
(
    [0] => 0
    [1] => 297
)
大批
(
    [0] => 3
    [1] => 298
)
大批
(
    [0] => 0
    [1] => 299
)
大批
(
    [0] => 0
    [1] => 300
)
大批
(
    [0] => 3
    [1] => 301
)
4

2 回答 2

4

您可以使用

$a = $b = array();
foreach ( $array as $list ) {
    list($a[], $b[]) = $list;
}

观看现场演示

于 2012-10-20T13:34:43.130 回答
2

像这样的东西?

$first = array();
$second = array();
$sourceArray = //this is what you are looping over. 
//Your loop
foreach($sourceArray as $array) {
    $first[] = $array[0];
    $second[] = $array[1];
}
于 2012-10-20T13:33:33.887 回答