0

我需要从容器内的所有图像中获取所有源值。我对此有一些困难。

请允许我解释一下这个过程。所有的数据都来自一个数据库。在后台,用户在文本区域内输入所有文本和图像。要将文本与图像分开,用户必须输入分页符。让我们去代码

while ($rowClients = mysql_fetch_array($rsClients)) {
    $result = $rowClients['content'];
    $resultExplode = explode('<!-- pagebreak -->', $result);
    // with resultExplode[0] I get the code and with resultExplde[1] I get the image

    // Now with I want to get only the src value from resultExplode[1]

我已经尝试过strip_tags

$imageSrc = strip_tags($resultadoExplode[1]);

但它不打印任何东西。

我找到了这篇文章,但没有成功。我停在第一个 print_r。

谁能帮我??

谢谢

4

2 回答 2

0

尝试foreach,如果你不能打印出来..(如果那是问题)

  foreach($resultExplode as $key => $value){
    echo "[".$key."]".$value;
    }
于 2012-08-22T08:52:50.877 回答
0

我找到了一个解决方案:

继续前面的代码,我使用了 split 函数。

所以我开始剥离标签。这样我就可以将 img 与其他部分隔离开来。

$image = strip_tags($resultExplode[1],"<img>");

因为所有的 img 都具有这样的结构:<img width="111" height="28" alt="alternative text" src="/path/to/the/file.png" title="title of the image">

我拆分这个字符串,使用 " 作为分隔符

$imgSplit = split('"', $image);
$src = $imgSplit[3];

瞧。它正在工作

你对这个程序有什么看法??

于 2012-08-22T13:48:16.130 回答