<?php
function writeMsg() {
$tab ="<div class='functiontest'>";
echo "test";
$tab .="</div>";
return $tab;
}
$test = writeMsg();
echo "<div class='wrapper'>";
for( $i=0; $i < 6; $i++ ){
echo "<div>" . $test . "</div>";
}
echo "</div>";
?>
.functiontest{
width:200px;
height:200px;
display:block;
background-color:#F4F5BD;
float:left;
}
.wrapper{
background-color:#F7ABAC;
display:block;
width:1000px;
min-height:1000px;
float:none;
clear:both;
box-sizing:border-box;
}
.wrapper div{
width:330px;
height:300px;
border:1px solid black;
float:left;
margin-left:7px;
margin-bottom:10px;
display: block;
background:#cccccc;
text-align: center;
}
.wrapper div:nth-child(2n+1){
clear:left;
}
<div class='wrapper'>
<div><div class='functiontest'>test</div></div>
<div><div class='functiontest'>test</div></div>
<div><div class='functiontest'>test</div></div>
<div><div class='functiontest'>test</div></div>
<div><div class='functiontest'>test</div></div>
<div><div class='functiontest'>test</div></div>
</div>
for( $i=0; $i < 6; $i++ ){
echo $test;
}
<div class='wrapper'>
<div class='wrapper2'><div class='functiontest'>test</div></div>
<div class='wrapper2'><div class='functiontest'>test</div></div>
<div class='wrapper2'><div class='functiontest'>test</div></div>
<div class='wrapper2'><div class='functiontest'>test</div></div>
<div class='wrapper2'><div class='functiontest'>test</div></div>
<div class='wrapper2'><div class='functiontest'>test</div></div>
</div>
for( $i=0; $i < 6; $i++ ){
echo "<div class='wrapper2'>" . $test . "</div>";
}
<div class='wrapper'>
<div class='functiontest'>test</div>
<div class='functiontest'>test</div>
<div class='functiontest'>test</div>
<div class='functiontest'>test</div>
<div class='functiontest'>test</div>
<div class='functiontest'>test</div>
</div>
<!doctype html>
<head>
<style>
.functiontest{
width:200px;
height:200px;
display:block;
background-color:#F4F5BD;
float:left;
}
.wrapper{
background-color:#F7ABAC;
display:block;
width:1000px;
min-height:1000px;
float:none;
clear:both;
box-sizing:border-box;
}
.wrapper div:nth-child(2n+1){
clear:left;
}
</style>
</head>
<body>
<div class='wrapper'>
<div class='functiontest'>test</div>
<div class='functiontest'>test</div>
<div class='functiontest'>test</div>
<div class='functiontest'>test</div>
<div class='functiontest'>test</div>
<div class='functiontest'>test</div>
</div>
</body>
</html>
.functiontest{
width:200px;
height:200px;
display:block;
background-color:#F4F5BD;
float:left;
}
.wrapper{
background-color:#F7ABAC;
display:block;
width:1000px;
min-height:1000px;
float:none;
clear:both;
box-sizing:border-box;
}
.wrapper div:nth-child(2n+1){
clear:left;
}
<?php
function writeMsg() {
$tab ="<div class='functiontest'>";
echo "test";
$tab .="</div>";
return $tab;
}
$test = writeMsg();
echo "<div class='wrapper'>";
for( $i=0; $i < 6; $i++ ){
echo $test; // <--no additional div here
}
echo "</div>";
?>
.functiontest{
width:200px;
height:200px;
display:block;
background-color:#F4F5BD;
float:left;
}
.wrapper{
background-color:#F7ABAC;
display:block;
width:1000px;
min-height:1000px;
float:none;
clear:both;
box-sizing:border-box;
}
.wrapper div:nth-child(2n+1){
clear:left;
}
Are you really Ok? You lack a lot of HTML and CSS knowledge it seems.
.wrapper div.functiontest{
width:200px;
height:200px;
display:block;
background-color:#F4F5BD;
float:left;
}
<div class='wrapper'>
<div><div class='functiontest'>test</div></div>
<div><div class='functiontest'>test</div></div>
<div><div class='functiontest'>test</div></div>
<div><div class='functiontest'>test</div></div>
<div><div class='functiontest'>test</div></div>
<div><div class='functiontest'>test</div></div>
</div>
<div class='wrapper'>
<div class='functiontest'>test</div>
<div class='functiontest'>test</div>
<div class='functiontest'>test</div>
<div class='functiontest'>test</div>
<div class='functiontest'>test</div>
<div class='functiontest'>test</div>
</div>
this should work "better", and provide you the divs with the test X inside
Open in new window