Code: Select all
echo 'blah' . $Answers[$Questions[$i]['question_id']][$j]['answer'] . 'blah';
// or something simple like..
echo 'blah' . $Answers[$i]['answer'] . 'blah';
Moderator: General Moderators
Code: Select all
echo 'blah' . $Answers[$Questions[$i]['question_id']][$j]['answer'] . 'blah';
// or something simple like..
echo 'blah' . $Answers[$i]['answer'] . 'blah';
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
So don't do that.
It looks like the parser is attempting to convert the array into a string before reading the whole line of code. Does the problem disappear if you save the part of the array you're after in a normal variable, and then concatenate it? If so, then this is indeed a PHP bug.astions wrote:I'm saying that regardless of what that contains, or if it's not set, it should not cause a fatal error.
'./configure' '--enable-memcache' '--with-apxs2=/usr/local/apache/bin/apxs' '--with-mysqli=/usr/bin/mysql_config' '--with-mysql=/usr/bin/mysql_config' '--prefix=/usr/local/apache/php' '--with-config-file-path=/usr/local/apache/php' '--enable-force-cgi-redirect' '--disable-cgi' '--with-zlib' '--with-jpeg-dir=/usr/local/src/jpeg-6b/' '--with-png-dir=/usr' '--with-gd' '--with-curl=/usr' '--with-mcrypt=/usr'
Code: Select all
<?php
$Answers = '';
$Questions[1]['question_id'] = 'test';
if (isset($Answers[$Questions[1]['question_id']][1]['answer']))
{
echo $Answers[$Questions[1]['question_id']][1]['answer'];
}
Code: Select all
<?php
$Answers = array();
$Questions[1]['question_id'] = 'test';
if (isset($Answers[$Questions[1]['question_id']][1]['answer']))
{
echo $Answers[$Questions[1]['question_id']][1]['answer'];
}
Code: Select all
$string = 'test' ;
echo $string[0] ; // this is ok
echo $string[6] ; // this returns a notice as that index is not initialized
isset($string[6]) ; // This is ok and no notice. Index 6 is not initialized but its still possible
echo $string['someindex'] ; // This should throw an error. You can never access a string via a a string index
isset($string['someindex']); // This should also throw an error because accessing a string via a string index is breaking the rules and there will never be a situation where isset() will return true if $string is of type string.http://de2.php.net/string wrote:Note: They may also be accessed using braces like $str{42} for the same purpose. However, using square array-brackets is preferred because the {braces} style is deprecated as of PHP 6.
I don't agree with that at all. Brackets should strictly be reserved for array indexes and braces should be strictly reserved for string offsets. Using brackets for both is just plain silly as you won't know by looking at it whether it's an array or string offset.volka wrote:If it is a bug it's by designhttp://de2.php.net/string wrote:Note: They may also be accessed using braces like $str{42} for the same purpose. However, using square array-brackets is preferred because the {braces} style is deprecated as of PHP 6.
Yes, I knew that but my opinion regarding to this would be:volka wrote:http://de2.php.net/string wrote:Note: They may also be accessed using braces like $str{42} for the same purpose. However, using square array-brackets is preferred because the {braces} style is deprecated as of PHP 6.
astions wrote:I don't agree with that at all. Brackets should strictly be reserved for array indexes and braces should be strictly reserved for string offsets. Using brackets for both is just plain silly as you won't know by looking at it whether it's an array or string offset.
Code: Select all
echo $array[1][1];Code: Select all
echo $array[1][1];