<?php
$str = <<<str
    <img src="1.jpg"/>
    <p>123123</p>
    <span>3322</span>
    <img src="https://www.baidu.com/2.png" alt="">
    <img src="https://www.baidu.com/2.jpeg" alt="">
    <img src="https://www.baidu.com/2.bmp" alt="">
    <img src="https://www.baidu.com/2.bmp" alt="">
    <img src='https://www.baidu.com/2.bmp' alt="">
str;

preg_match_all( '~<img.*?src=["\']+(.*?)["\']+~' , $str, $match );

p($match['1']);

/**Array
(
    [0] => 1.jpg
    [1] => https://www.baidu.com/2.png
    [2] => https://www.baidu.com/2.jpeg
    [3] => https://www.baidu.com/2.bmp
    [4] => https://www.baidu.com/2.bmp
    [5] => https://www.baidu.com/2.bmp
)
**/

function p($var)
{
    if (is_bool($var)) {
        var_dump($var);
    } else if (is_null($var)) {
        var_dump(NULL);
    } else {
        echo "<pre style='position:relative;z-index:1000;padding:10px;border-radius:5px;background:#F5F5F5;border:1px solid #aaa;font-size:14px;line-height:18px;opacity:0.9;'>" . print_r($var, true) . "</pre>";
    }
}

Thinkphp5 in查询结果按照in里面的顺序排

或许有人会注意过,但我以前真不知道 SQL: select * from table where id IN (3,6,9,1,2,5,8,7); 这样的情况取出来后,其实,id还是按1,2,3,4,5,6,7,8,9,排序...

阅读全文

一款好用的sitemap 生成类库 samdark/sitemap

github地址 安装 composer require samdark/sitemap 使用 use samdark\sitemap\Sitemap; use samdark\sitemap\Index; // create sitemap $sitemap = new Sit...

阅读全文

一个好用的 php websocket 类库 ratchet

github 官网 安装 //安装 composer require cboden/ratchet 创建自己的websocket类库 <?php namespace MyApp; use Ratchet\MessageComponentInterface; us...

阅读全文

欢迎留言