php - print value of a variable that is composed for a string into a For Loop -


in loop, i'm trying take value of variable, save code want use loop print concatenating part of variable number genereted loop. try.

<?php $x0 = 0; $x1 = 1; $x2 = 2; $x3 = 3;  ($i=0; $i < 5; $i++) { echo '$x'.$i;    } ?> 

the result i'm geting

$x0$x1$x2$x3$x4

i want end this:

0123

its supposed be:

for ($i=0; $i < 5; $i++) {     echo ${"x$i"}; } 

sidenote: you'll have define $x4 or terminate < 4 won't undefined index.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -