Jump to content

[SOLVED] spaces in image names


SchweppesAle

Recommended Posts

actually, there are sometimes multiple images. 

 

The database itself is part of a Joomla 1.5 CMS.  Usually, images are stored with the following format

 

<img align="left" width="209" src="../images/stories/intuit logo new for 2008.jpg" height="90" />

 

They're in there with the actual content though, so I'm not really sure how to get in there and modify only the required src = "" string

Since the request was for regex, I moved the thread to the regex board. Please note this board for future regex requests.

 

Database issues not withstanding, if going the regex route, is this something along the lines of what you are looking for?

 

$str = 'img align="left" width="209" src="../images/stories/intuit logo new for 2008.jpg" height="90" />';
if(preg_match_all('#src=[\'"][^\'"]+[\'"]#i', $str, $matches)){
foreach($matches[0] as $val){
	$str = str_replace($val, str_replace(' ',"%20",$val), $str);
}
}
echo $str; // ouputs: img align="left" width="209" src="../images/stories/intuit%20logo%20new%20for%202008.jpg" height="90" />

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.