开发者

PHP Double Quotes In Array Key

I know this is really bad practice, but it's already been put in place because it is an existing system. Anyways, I have a table that has an id and a description.开发者_JAVA技巧 What the code does is it creates an array from this table, but to make it easy to search, we made the description they key and the id the value. Now the issue is that the description contains double quotes, example 4"x6", and that is preventing the program from finding the id. Is there any special escape sequence that I can use to get around this issue?

Here is an example of simplified code:

$my_ary = array('4"x6"'=>22, 'test'=>3);

echo $my_ary['4"x6"']; // Does not work
echo $my_ary['test']; // Works

$quote_key = '4"x6"';
echo $my_ary[$quote_key]; // Does not work

Hopefully with that example that will help out my explination.

this is with version 5.2.6-3ubuntu4.2 of PHP


It actually works for me on php 5.3.2


Your code works for me under PHP 5.3.2.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜