On 19 Apr 2012, at 15:46, Ron Piggott wrote:
> I am trying to assign variables from an array into variables. This is
> following a database query. Right now they are in an array:
>
> $row[‘word_1’]
> $row[‘word_2’]
> $row[‘word_3’]
> ...
> $row[‘word_25’]
Why those indices? Why isn't it just a numerically indexed array?
> I am trying to use this while look to assign them to variables:
> $word_1
> $word_2
> $word_3
> ...
> $word_25
The first question that comes to mind is why the heck you would want to do such
a thing?
> ${'word_'.$i} = stripslashes( eval ("echo $row['word_$i']") );
Eww, nasty. Why the eval? Why not just stripslashes($row['word_'.$i])?
Variable variables have their uses, but this seems to be one of those cases
where you're trying to get the square peg through the triangular hole. Take a
step back and give us some more context.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php