<?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>";
    }
}

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

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

阅读全文

使用php hdfs 读取大文件

最近用hdfs上传了一个2.8g的视频,发现用原始的read方式会把整个视频加载到内存,会非常慢。所以使用hdfs的web api里面的按文件偏移量加载的方式。 参考:htt...

阅读全文

php获取字符串中的数字

$str = 'aasd222ssdd32'; $str = preg_replace("/[^0-9]/","",$str); echo $str;

阅读全文

欢迎留言