爲什麼下面的代碼:定義索引+元素
if (isset($_GET['trainType']) && isset($_GET['onTime']) && isset($_GET['gotSeat'])) {
$train[0]['trainType'] = $_GET['trainType'];
$train[0]['trainType']['onTime'] = $_GET['onTime'];
$train[0]['trainType']['gotSeat'] = $_GET['gotSeat'];
echo '<pre>';
print_r($train);
echo '</pre>';
}
返回以下陣列:
Array
(
[0] => Array
(
[trainType] => tLine
)
)
我最初以爲它會返回一些更類似於此:
Array
(
[0] => Array
(
[trainType] => 'passenger'
Array =>
(
[onTime] => true
[gotSeat] => true
)
)
)
任何指導我應該做什麼來實現我想要做的事情?我希望我的代碼使我想要做的事明顯。
可以的var_dump()你的$ _GET數組? –
'trainType = string'VLine'(length = 5) onTime = string'true'(length = 4) gotSeat = string'true'(length = 4)' – anditpainsme
'所以你試圖追加到字符串它是一個數組 –