php preg_match_all 使用问题查出太多无用东西

来源:百度知道 编辑:UC知道 时间:2024/06/07 13:27:54
<?php

$content1 = '
<div class="txt" style="margin:auto;"><a href="http://banner-host.info/products/Louis-Vuitton-Mahina-Leather-XL-M95552-GREY-GREEN.html"> <img border="0" alt="Louis Vuitton XL pics" src="http://banner-host.info/product_image/M95552 GREY GREEN/0/2.jpg" ></a></div>
<div class="product-name"><a href="http://banner-host.info/products/Louis-Vuitton-Mahina-Leather-XL-M95552-GREY-GREEN.html">Louis Vuitton XL</a></div&g

看到了hcl198925 的回答,可是如果我的返回结果不是两条而是三条,可是不确定有多少条怎么办?所以我的办法是写一个自定义的函数。
代码如下:
<?php
/*
* Author : Fanglor
* Email : Fanlor@163.com
* Url : www.skyleft.com
* Date : 2009-10-10
*/
$arr = Array
(
Array
('src="http://banner-host.info/product_image/M95552 GREY GREEN/0/2.jpg"',
'M95552 GREY GREEN/0/2',
'jpg'
),

Array
('src="http://banner-host.info/product_image/M95546 WHITE/0/2.jpg"',
'M95546 WHITE/0/2',
'jpg'
)

);
function cute_str ($arr) {
$a