If I'm reading your snippet correctly, then :
$foo = 'bar';
$bar = array('apple','banana');
print ${$foo}[0]; // apple
Note the use of {braces}. The last paragraph in the manual describes this
a bit :
http://www.php.net/manual/en/language.variables.variable.php
Although I don't see the point of $newvar as you're keeping track of $a in
the array itself. Looks like the below code will create a ton of
variables (arrays) each with one $a as the single key. Just using
$finalresult may be more appropriate, hard to say.
And some tips :
$arr[foo] will create an error/warning here, $arr['foo'] will not.
"$foo" isn't as pretty as $foo
regards,
Philip Olson
On Wed, 26 Sep 2001, Richard Baskett wrote:
> I can not figure out why this is not working!
>
> for ($j=0; $j<$resultNum; $j++) {
> $newvar = "finalresult".$a;
> $$newvar[$a][name] = $resultRow[name];
> $$newvar[$a][title] = $resultRow[title];
> $$newvar[$a][descript] = $resultRow[descript];
> $$newvar[$a][countkey] = substr_count("$resultRow[keywords]", "$keyword");
> a++;
> }
>
> This is how you use variable variables, is it not? Is it because it's a
> multidimensional array? or am I missing something else?
>
> Rick
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]