Skip to content

berry.utils.HTMLHelper

Nikos Siatras edited this page Sep 30, 2022 · 12 revisions
require_once(__DIR__ . "/berry/utils.php"); // Include berry encryption package

$htmlStringWithImages = '<span>Hello this is an image <img src="myImage1.png" alt="Image"> and here is an other one <img src="myImage2.png" alt="An other one..."></span>';
$htmlHelper = new HTMLHelper();

// Get all <img> tags from $htmlStringWithImages string 
$images = $htmlHelper->GetAllTagsFromHTMLString("img", $htmlStringWithImages);

print_r($images);

The above code out put is:

Array
(
    [0] => <img src="myImage1.png" alt="Image">
    [1] => <img src="myImage2.png" alt="An other one...">
)
Clone this wiki locally