How to extract base64 image from text? I tried to use simple html dom library but couldn't extract it from text. I need to extract each base64 and convert it to an image then save it to public folder.
Code:
$post = \App\Post::find(45);
$dom = HtmlDomParser::str_get_html( $post->content );
foreach ($dom->find('data:image') as $element) {
dd($element);
}
<p style="text-align:right"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to ma</p>
<p style="text-align:right">data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB .... == </p>