Page 1 of 1

do inside a variable

Posted: Sat Nov 15, 2003 5:08 am
by Cwin
Is there any way to put a do{} inside a variable?
Like:

Code: Select all

$x = do {echo "something";} while ($y==1);
i know that doesn't work, but is there any way to make it work?

Code: Select all

[i]Why?.... read on[/i]

<?php
   function cwinsfunc($arg) {
   //This is where there is some code
   $x = 1;
   return <<<EOF
      This is a load of HTML<br>
      PHP will only replace variables, nothing else<br>
      echo ("hi") will return echo ("hi")<br>
      $x will return 1<br>
      <b>Bold Text</b><br>
      <br>
      So obviously i cant put a do in here
   EOF;
}

Posted: Sat Nov 15, 2003 11:24 am
by d3ad1ysp0rk
split your variable in half?

$x1 = all the HTML before the do loop
$x2 = everything afterwards

echo $x1;
do {} while loop;
echo $x2;

im not really sure what you're looking to do (or display).. hope i helped tho