2

I am new to Yii. I define an array as follows:

$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 ) ) );

But there is a syntax error:

Syntax error:
expected: instanceof, OR, XOR, AND, ?, ';', ||, &&, |, ^, &, ==, !=, ===, !==, <=+, >=+, <, >, <<, >>, +, -, *, /, %, '.'

Any suggestions would be appreciated.

Thank You

2
  • What language is this? Commented Aug 25, 2014 at 15:31
  • It's Yii. The language is PHP Commented Aug 25, 2014 at 15:34

2 Answers 2

2

That's not php notation. It should be this way:

$simplified_list = array(
    'data' => array(
        0 => array(
            'name' => '4MB 1Day',
            'data_volume' => '4 MB',
            'tariff' => 2,
            'tariff_with_vat' => 2.3,
        ),

        [...]
    )
);
Sign up to request clarification or add additional context in comments.

Comments

0

Just try it this way:

$simplified_list = array ( 
        'data' => array (
            '0' => array ( 'name' => 4MB 1Day, 'data_volume' => '4 MB', 'tariff' => 2, 'tariff_with_vat' => 2.3 ) ...

More Information you can find here (your question has nothing to do with Yii, it's Basic PHP): http://php.net/manual/de/language.types.array.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.