Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 基于计数动态设置为_Php_Arrays_Dynamic - Fatal编程技术网

Php 基于计数动态设置为

Php 基于计数动态设置为,php,arrays,dynamic,Php,Arrays,Dynamic,我在我的网站上有一个砌体部分,根据该部分中的项目数量,每个单独的部分将有不同的宽度。现在我正在手动设置每个项目的宽度。有更好的办法吗 if($postCount == 1){$width = array("1-1");} if($postCount == 2){$width = array("2-3","1-3");} if($postCount == 3){$width = array("1-3","1-3","1-3");} if($postCount == 4){$width = arra

我在我的网站上有一个砌体部分,根据该部分中的项目数量,每个单独的部分将有不同的宽度。现在我正在手动设置每个项目的宽度。有更好的办法吗

if($postCount == 1){$width = array("1-1");}
if($postCount == 2){$width = array("2-3","1-3");}
if($postCount == 3){$width = array("1-3","1-3","1-3");}
if($postCount == 4){$width = array("2-3","1-3","2-3","1-3");}
if($postCount == 5){$width = array("2-3","1-3","1-3","1-3","1-3");}
if($postCount == 6){$width = array("1-3","1-3","1-3","1-3","1-3","1-
3");}
if($postCount == 7){$width = array("2-3","1-3","1-3","1-3","1-3","2-
3","1-3");}
if($postCount == 8){$width = array("2-3","1-3","1-3","1-3","1-3","1-3","1-3","1-3");}