What does the comma mean in an echo expression?
I am trying to repeat a line from the Recursive function:echo "<li>", $node, recurse($arr), "</li>";
andecho "<li>" . $node . recurse($arr) . "</li>";
function writeList($tree)
{
if($tree == null) return;
echo "<ul>";
foreach($tree as $node=>$children) {
echo "<li>", $node, writeList($children) , "</li>";
}
echo "</ul>";
}
$treeis a tree structure as can be found in this question (form2)
And, I can notice that the result is from two different.
Can someone tell me the difference in use ,and .in general and, in particular, in this example?
EDIT : what if, instead of repeating the lines, I want to save the line generated from this function in a variable. I am particularly interested in the result obtained from the first operator echo.
EDIT: I feed on this array:
array
3 =>
array
4 =>
array
7 => null
8 =>
array
9 => null
5 => null
6 => null
The outputs I get:
(from the first echo expression)
<ul><li>3<ul><li>4<ul><li>7</li><li>8<ul><li>9</li></ul></li></ul></li><li>5</li></ul></li><li>6</li></ul>
(from the second expression of the echo)
<ul><ul><ul><li>7</li><ul><li>9</li></ul><li>8</li></ul><li>4</li><li>5</li></ul><li>3</li><li>6</li></ul>
EDIT: , . writeList(). echo.
:
echo "<li>", $node, writeList($arr), "</li>";
, . :
echo "<li>";
echo $node;
echo writeList($arr);
echo "</li>";
:
echo "<li>" . $node . writeList($arr) . "</li>";
., . , writeList($arr) , then echo.
, . , , , echo .
, , , , . , , , .
.
ob_start();
echo "<li>", $node, writeList($arr), "</li>";
$out = ob_get_clean();
, ?
$out = "<li>" . $node . writeList($arr) . "</li>";