1

I have an array but something goes wrong with it, here is my code :

 $date = array (1 => "$row['turning']", 2 => "$row['smiling']");     

and this code is displaying this error

unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

some light please .

1 Answer 1

5

If your variable is an array then you need to enclose it in curly brackets:

$date = array (1 => "{$row['turning']}", 2 => "{$row['smiling']}");

Although you should just do:

$date = array (1 => $row['turning'], 2 => $row['smiling']);
Sign up to request clarification or add additional context in comments.

4 Comments

thanks so much :) , its right :), it works like a charme now .
1- for ($j=1 ; $j <= 10 ; $j ++){ 2- $date = array (1 => $row['turning'], 2 => $row['smiling']); 3- $year."$j"= substr($date[$j], 6, 4) ; } say that i have date like that 2012-03-25 after this code i get this error unexpected '=' in line 3 something wrong there ?
You can't concatenate two variables and then try to assign a value to it.
i mean i wanted get date1 and date2 from each one (turning and smiling columns ), is there someway better ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.