or you can do this
echo $row["Bible_knowledge_phrase_solver_game_question_topics_$i"];
-Original Message-
From: Ron Piggott [mailto:ron.pigg...@actsministries.org]
Sent: Thursday, June 21, 2012 3:47 AM
To: php-general@lists.php.net
Subject: [PHP] Variable representation
I am trying to represent the variable:
$row['Bible_knowledge_phrase_solver_game_question_topics_1']
On Mon, Apr 2, 2012 at 4:34 AM, Maciek Sokolewicz
wrote:
> Usually if you think you need to use eval: think again. In this case, it
> again holds true.
>
> Instead of doing what you do, you can also reference the variable as:
> echo ${'image_'.$i};
> or
> echo $GLOBALS['image_'.$i];
>
> Both are p
On 02-04-2012 07:15, tamouse mailing lists wrote:
As for doing what you originally asked, that requires doing an eval()
on the statement utilizing string interpolation, like so:
eval('echo "image $i is $image_' . $i . '".PHP_EOL;');
but I think that's a bit harder to read and understand what
On Mon, Apr 2, 2012 at 12:20 AM, tamouse mailing lists
wrote:
> Ugh, gmail mangled the code there. Here's a pastebin of the response
> which is better formatted: http://pastie.org/3712761
Sweet. I spent so long on my reply, two others snuck in before me. :)
--
PHP General Mailing List (http://w
Ugh, gmail mangled the code there. Here's a pastebin of the response
which is better formatted: http://pastie.org/3712761
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
On Sun, Apr 1, 2012 at 10:52 PM, Ron Piggott
wrote:
> Hi Everyone:
>
> I am assigning the value of 4 images to variables following a database query:
>
> $image_1 = stripslashes( $row['image_1'] );
> $image_2 = stripslashes( $row['image_2'] );
> $image_3 = stripslashes( $row['image_3'] );
> $image_
On 04/02/2012 07:46 AM, Adam Randall wrote:
$images[] = stripslashes( $row['image_1'] );
$images[] = stripslashes( $row['image_2'] );
$images[] = stripslashes( $row['image_3'] );
$images[] = stripslashes( $row['image_4'] );
$images[1] = stripslashes( $row['image_1'] );
$images[2] = strips
On 04/02/2012 06:52 AM, Ron Piggott wrote:
$image_1 = stripslashes( $row['image_1'] );
$image_2 = stripslashes( $row['image_2'] );
$image_3 = stripslashes( $row['image_3'] );
$image_4 = stripslashes( $row['image_4'] );
[...] (Not all 4 variables have an image.)
How is it meant in the database?
It would better to just use an array, and then iterate through that.
$images[] = stripslashes( $row['image_1'] );
$images[] = stripslashes( $row['image_2'] );
$images[] = stripslashes( $row['image_3'] );
$images[] = stripslashes( $row['image_4'] );
foreach( $images as $k => $v ) {
$k++; /
10 matches
Mail list logo