|
|
|
|
![]() ![]() |
Feb 22 2008, 12:52 AM
Post
#1
|
|
|
Newbie [Level 3] ![]() ![]() ![]() Group: [HOSTED] Posts: 48 Joined: 21-January 08 Member No.: 56,591 |
this is an error i have dealt with for a long time and it doesn't really make much sense to me.
if i am parsing a string, and try to put an array variable in it, it returns an error example: CODE echo "This is a variable: $array['var']"; that will return an error. I have tried to get around it by doing $array[\'var\'] and $array[\"var\"] but those just return different errors. I can get rid of the error by using this: $array[var] but it says right in the php manual that that is a no-no the only two ways i know to escape are to assign the value to a string variable or to concatenate. CODE $var = $array['var']; echo "This is a variable: $var" CODE echo "This is a variable: " . $array['var']; the first is rather cumbersome with large arrays, and the second is kind of messy the way i see it. does anyone know how to get around this? |
|
|
|
Feb 22 2008, 01:19 AM
Post
#2
|
|
|
|||[ n00b King ]||| ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 681 Joined: 20-June 07 From: Auckland Member No.: 45,102 |
I dont know what it's called but I came across it somewhere.. cant remember that either lol. anywhere here it is and this is what i use
CODE echo"<span class='header'>Title</span> {$rs['title']}"; if I don't use the {} around the array/resource, it won't work. hope that helps ya out and if anyone can shed some light on its former name and use of the {} in this case, it would be appreciated. |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 8th September 2008 - 06:13 PM |