Home > Article > Backend Development > Reading images implemented in php into tables_PHP tutorial
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 "
"; | |
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 " | "; |