代码

<?php

$html = <<<str
<html>
<head>
    <title>123</title>
</head>
<body>
    <img src="http://1.jpg" alt="">
    <img src="http://2.jpg" alt="">
    <img src="http://3.jpg" alt="">
    <img src="http://4.jpg" alt="">
    <img src="http://5.jpg" alt="">
</body>
</html>
str;

    //读取字符串
    $doc = new \DOMDocument();
    $doc->loadHTML($html);

    $xpath = new \DOMXPath($doc);
    //解析src
    $imgs = $xpath->query('//img/@src');

    dump($imgs);

    foreach ($imgs as $v) {
        dump($v);
    }

结果

file

php-rdkafka测试笔记

参考:https://learnku.com/articles/15176/laravel-implementation-of-kafka-message-push-and-receive-processing 安装 安装librdkafka 库 git clone https...

阅读全文

推荐一个好用的php日志类库,monolog/monolog

github仓库地址 官方文档: https://github.com/Seldaek/monolog/blob/main/doc/01-usage.md 安装 $ composer require monolog/monolog 使用方法 <?php us...

阅读全文

php 二维数组根据某个键值倒叙、升序排序

<?php $array = [ [ 'title' => '标题5', 'views' => 500 ], [ 'title&...

阅读全文

欢迎留言