RE: Variable Variable Array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Do you mean something like this:

http://www.weberdev.com/get_example-4065.html

It creates a quick associative array from the resultset

Bastien

From: "Ryan Jameson (USA)" <RJameson@xxxxxxxxxxx>
To: <php-db@xxxxxxxxxxxxx>
Subject:  Variable Variable Array
Date: Thu, 10 Mar 2005 11:56:16 -0700

Hi Folks,

I've been using "variable variables" for years with PHP.

$var = "myVarName";
$$var = "Some Val";

echo $myVarName; //outputs "Some Val"


... Today I am trying to assign an Associative Array value to a "variable variable". For some reason it doesn't take. Does anyone know why?

Example:

$var['first']='bob';
$var['second']='frank';

$varName = "myVarName";
$$varName = $var;

echo $$varName['second']; //should output "frank" but doesn't. :-\
<-----------------------------
echo $var['second']; //should output "frank" works fine.


The reason I want to do this is to speed up access to DATABASE query results by use of the associative array. Since the results are keyed on a specific column I'd like to load the very small recordset and then access each row associatively on that column value. Currently I have to requery the database every time, which is faster than loop/testing the whole result set each time. I'd use a hashtable in Java but PHP ain't Java. If ne1 has a better way I'm game.

Thanks for your help.
<>< Ryan

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux