Page 1 of 1

echoing dynamic variables[SOLVED]

Posted: Sat Oct 08, 2005 4:56 am
by raghavan20
The explanation is given in the comments.
I am trying to print all the variables values from h0...h4.
but this displays as
Notice: Undefined variable: h in /home/www/raghavan.100webcustomers.com/Sha1.class.php on line 34

Notice: Undefined variable: h in /home/www/raghavan.100webcustomers.com/Sha1.class.php on line 34


Notice: Undefined variable: h in /home/www/raghavan.100webcustomers.com/Sha1.class.php on line 34

Notice: Undefined variable: h in /home/www/raghavan.100webcustomers.com/Sha1.class.php on line 34

Notice: Undefined variable: h in /home/www/raghavan.100webcustomers.com/Sha1.class.php on line 34

Code: Select all

/* encrypt if initial conditions are met */
	if (isset($_GET["input_string"])){
		/* define initial variables */
		$h0 = "67452301";
		$h1 = "EFCDAB89";
		$h2 = "98BADCFE";
		$h3 = "10325476";
		$h4 = "C3D2E1F0";
	}
	
	for ($i = 0; $i < 5; $i++){
		echo $h{$i}. "<br />"; //-------->>This line should print values of $h0, $h1...$h4. How shd I do that???
	}

Posted: Sat Oct 08, 2005 5:37 am
by n00b Saibot

Code: Select all

echo ${'h'.$i}. "<br />";

Posted: Sat Oct 08, 2005 6:33 am
by raghavan20
that works!!! thanks very much