Home  >  Article  >  Backend Development  >  Reading images implemented in php into tables_PHP tutorial

Reading images implemented in php into tables_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:44:381056browse

To be precise, it should be a small technical issue. I usually don't pay attention to it, but when I really want to achieve this effect, I realize that it is not that simple. There are many detailed issues that need to be solved one by one, such as tables. The damage problem, I was very entangled with this problem at first, but now it’s fine, I’ve finally solved it, this hurdle has finally been passed, I’ll share the code with you

/*
First, convert the array into a numeric index array, and then loop the numeric index array
*/
$arr=array (
"apple" => "./img/apple.jpg",
"banana" => "./img/banana.jpg",
"caomei" => ". /img/caomei.jpg",
"zaozi" => "./img/zaozi.jpg",
"orange" => "./img/orange.jpg",
" lizi" => "./img/lizi.jpg",
"shizi" => "./img/shizi.jpg"
);

//Associative array is converted to Numeric index array
$row=array();
foreach($arr as $key=>$a_v){
$row[]=$a_v;
}
// Loop through the numeric index array into the table. Of course you can also use foreach here, but I use the more traditional loop method for,
echo "

for($i=0;$i $a=false;
echo "
";
if(($i+1)%3 == 0 && $i != 0){
echo "";
$a=true;
}
}
/*The code below is the key to this technical problem, and its function is to Complete the empty cells ";
}
}
echo "
to avoid breaks in the table. I believe everyone can understand the specific meaning of the code, so there is no need to be picky about readability.
*/
$remainder=(count($ row))%3;
$a=3-$remainder;
if($remainder!=0){
for($i=1;$i<=$a;$i++){
echo "
 
";
?>
The effect before adding the last code

The effect after adding the last code

Compare the difference between the two and you will understand my good intentions

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478738.htmlTechArticleTo be precise, it should be a small technical issue. I usually don’t care about it, but I really want to achieve this. Only when I saw the effect did I realize that it was not that simple. There were a lot of detailed issues that needed to be addressed...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn