Is it possible in php to make the second div appears inside the first one instead of getting two separated divs ? I would like to make a php dom system but I'm stuck with this problem.
This is the HTML I get when the page returns :
<div style="width:
50px;
height:
30px;
background-color:
yellow;
color:white
">
blablabla
</div>
<div style="width:
200px;
height:
50px;
background-color:
blue;
color:white
">
</div>
This is the PHP code :
<? php
function genDiv($width, $height, $bgColor, $add, $content) {
echo '
<div style=\'width:
'.$width.';
height:
'.$height.';
background-color:
'.$bgColor.';
'.$add.'
\'>
'.$content.'
</div>
';
}
$block = genDiv(
'50px',
'30px',
'yellow',
'color:white',
'blablabla'
);
genDiv(
'200px',
'50px',
'blue',
'color:white',
$block
);
?>
You need to rewrite the function so it returns the HTML instead of echoing it out directly.
Then you can echo the result of the second call to the function.