echo数组有关问题

WBOY
Release: 2016-06-13 13:47:38
Original
1233 people have browsed it

echo数组问题
while($row=mysql_fetch_array($result))
{
list($x1,$y1) = explode('|',$row['xyz1']);
list($x2,$y2) = explode('|',$row['xyz2']);
……
$left=array($x1,$x2,……);
$top=array($y1,$y2,……);
}
 $notes.= '

'; 
?>

  

$x1,$x2,$y1,$y2存放的是DIV的TOP,LEFT坐标
但echo出来后只能看到一个DIV 而且并没有取得$left,$top的值

如果我写成
'
或者
'
则可以正常显示

由于我要echo的DIV很多,所以不可能自己一个一个地列举,请问怎么用单个句子把所有的DIV全部echo出来呢

试过用for判断
for($i=0;$i{
echo "
'
";
}

'.$left['.$i.'].' 不知道正确的表达方式是怎样的

另外
{
list($x1,$y1) = explode('|',$row['xyz1']);
list($x2,$y2) = explode('|',$row['xyz2']);
……
$left=array($x1,$x2,……);
$top=array($y1,$y2,……);
}
这个语句有什么方法可以直接合并为类似于下面这种表达式
list($left,$top)=array(explode('|',$row['xyz1']),explode('|',$row['xyz2']),……)
不然的话也是得自己一个个地列举出来


------解决方案--------------------
看看这个
PHP code
$ar = array (
array(
 'xy1' => '1,2',
 'xy2' => '3,4',
 'xy3' => '5,6',
 'xy4' => '7,8',
),
array(
 'xy1' => '11,12',
 'xy2' => '13,14',
 'xy3' => '15,16',
 'xy4' => '17,18',
),
);

foreach($ar as $r)
  foreach($r as $v)
    list($x[], $y[]) = explode(',', $v);

print_r($x);
print_r($y);
<br><font color="#e78608">------解决方案--------------------</font><br>
echo "<div class='\"note"' style='\"left:{$left[$i]}px;top:{$top[$i]}px\"'></div>";  <br><br>或者:<br>echo "<br><div class="note" style='left:".$left[$i]."px;top:".$top[$i]."px'></div><br>"; <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template