Answers for "php get text after first match"

PHP
1

get first word from string php

function getFirstWord($string)
    {
        $arr = explode(' ', trim($string));
        return isset($arr[0]) ? $arr[0] : $string;
    }
Posted by: Guest on February-26-2021
0

php get first two paragraphs

$str = "<p>This is one</p><p>This is two</p><p>This is three</p>";
$pattern="/(<p[^>]*>(.*)</p>){2}/isU";
preg_match($pattern,$str,$matches);
echo htmlentities($matches[0]);
Posted by: Guest on August-13-2021

Browse Popular Code Answers by Language