string - Search entire text for images -


i have problem project. need search string images. want source of image , modify html form of img tag. example image form is:

and want change to:

<div class="col-md-3"> <hr class="visible-sm visible-xs tall" /> <a class="img-thumbnail lightbox pull-left" href="upload/uploader/up_164.jpg" data-plugin-options='{"type":"image"}' title="image title"> <img class="img-responsive" width="215" src="upload/uploader/up_164.jpg"><span class="zoom"><i class="fa fa-search"></i> </span></a> 

i have done part of this.

i can find image, change form of html cannot loop images found in string.

my code goes like

using following function string between 2 strings

//  substring between function getbetween($var1="",$var2="",$pool){     $temp1 = strpos($pool,$var1)+strlen($var1);     $result = substr($pool,$temp1,strlen($pool));     $dd=strpos($result,$var2);     if($dd == 0){     $dd = strlen($result);     }      return substr($result,0,$dd); } 

and image tag string

$imagefile = getbetween("img","/>",$newtext); 

the next filter source of image:

$imagesource = getbetween('src="','\"',$imagefile); 

and last part call str_replace job:

$newtext = str_replace('oldform', 'newform', $newtext); 

the problem in case there more tha 1 images, cannot loop process.

thank in advance.

the best, simple , safe way read xml file use xml parser.

and, think gain lot of time.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -