如何在while循环中从函数返回值时在div外创建div [英] how to create div outside a div when returns a value from function in a while loop

查看:54
本文介绍了如何在while循环中从函数返回值时在div外创建div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将函数的返回值访问到while循环中时,我遇到了如何创建离散div的问题,但我希望将div创建在另一个之外,而不是在另一个内部创建。请参阅以下代码:

I am getting problem in how to create discrete divs when accessing the function's returned value into a while loop, but I want that divs to be created one outside the other instead of being created one inside the other. See the below code:

<html>
<head>
<title>sdcsdzc</title>
</head>
<body>
<?php

$j=0;
while($j<=2)
{                    $removed=array("http://www.w3schools.com/html/default.asp","http://www.w3schools.com/js/default.asp","http://www.w3schools.com/sql/default.asp");
$data=crawl_page($removed[$j]);
echo "
<div style=' background-color: #E7EFEF;width:84%;border:1px solid #A5BEBE;'> 
<div style='background-color: white;border:1px solid #A5BEBE;'>
$data[0]
</div>
</div>";
$j++;
}

function crawl_page($b)
{ 
$a=fopen($b,"r");
$contents=stream_get_contents($a);
fclose($a);
$contents=strtolower($contents);

$start='<div class="example"';

$start_pos=strpos($contents,$start);
$first_trim=substr($contents,$start_pos);

$stop='</div>';
$stop_pos=strpos($first_trim,$stop);

$second_trim=substr($first_trim,0,$stop_pos);

$out['0'] = $second_trim;
return $out;
}
?>
</body>
</html>





我无法向你发送我输出的图像但是你可以直接在php中运行这个代码并看到div正在另一个内部创建,但我希望它们一个接一个地离散出来。如果有人能做到这一点,请告诉我,这对我很重要!!



I cant send you the image of my output but you can run this code directly in php and see the divs are creating inside the other, but I want them to come out discretely one after the other. If anyone can do this please do tell me, its important for me !!

推荐答案

j = 0;
while(
j=0; while(


j< = 2)
{
j<=2) {


removed = array( http://www.w3schools.com/html/default.asp http://www.w3schools.com/js/default.asp < span class =code-string> http://www.w3schools.com/sql/default.asp);
removed=array("http://www.w3schools.com/html/default.asp","http://www.w3schools.com/js/default.asp","http://www.w3schools.com/sql/default.asp");


这篇关于如何在while循环中从函数返回值时在div外创建div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆