我是Yii的新手。我按如下方式定义数组:
$simplified_list = array (
[data] => array (
[0] => array ( [name] => 4MB 1Day [data_volume] => 4 MB [tariff] => 2 [tariff_with_vat] => 2.3 )
[1] => array ( [name] => 25MB 1Day [data_volume] => 25 MB [tariff] => 10 [tariff_with_vat] => 11.5 )
[2] => array ( [name] => 100MB 7Day [data_volume] => 100 MB [tariff] => 40 [tariff_with_vat] => 46 )
[3] => array ( [name] => 500MB 30Days [data_volume] => 500 MB [tariff] => 175 [tariff_with_vat] => 210.25 )
[4] => array ( [name] => 1GB 30Days [data_volume] => 1024 MB [tariff] => 275 [tariff_with_vat] => 316.25 )
[5] => array ( [name] => 2GB 30Days [data_volume] => 2048 MB [tariff] => 347 [tariff_with_vat] => 399 ) ) );
但是存在语法错误:
Syntax error:
expected: instanceof, OR, XOR, AND, ?, ';', ||, &&, |, ^, &, ==, !=, ===, !==, <=+, >=+, <, >, <<, >>, +, -, *, /, %, '.'
任何建议都将不胜感激。
谢谢
答案 0 :(得分:2)
那不是php表示法。它应该是这样的:
$simplified_list = array(
'data' => array(
0 => array(
'name' => '4MB 1Day',
'data_volume' => '4 MB',
'tariff' => 2,
'tariff_with_vat' => 2.3,
),
[...]
)
);
答案 1 :(得分:0)
试试这个:
$simplified_list = array (
'data' => array (
'0' => array ( 'name' => 4MB 1Day, 'data_volume' => '4 MB', 'tariff' => 2, 'tariff_with_vat' => 2.3 ) ...
您可以在此处找到更多信息(您的问题与Yii无关,它是基本的PHP): http://php.net/manual/de/language.types.array.php