代码

<?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

nginx 解析php conf配置文件

本博客的nginx 配置文件 server { listen 80;#80和443端口同时监听 listen 443 ssl; server_name www.koukousky.com koukousky.com...

阅读全文

php composer 安装阿里云镜像

#doc: https://developer.aliyun.com/composer 全局配置(推荐) composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ 取消配...

阅读全文

intervention/image处理IOS上传图片翻转问题

#安装 $ composer require intervention/image <?php use Intervention\Image\ImageManagerStatic as Image; //test.png要处理的图片路径 Image::make(&...

阅读全文

欢迎留言