Question

$str = http://captoons2.se7enmarketing.com/wp-content/uploads/2014/06/eden-apple.jpg 

I am having string as the guid in wordpress i want to convert it into

$str = http://captoons2.se7enmarketing.com/wp-content/uploads/2014/06/eden-apple-180x68.jpg 
Was it helpful?

Solution

Try this.

<?php

$str = 'http://captoons2.se7enmarketing.com/wp-content/uploads/2014/06/eden-apple.jpg';
$names = pathInfo($str);
echo $names['dirname'].'/'.$names['filename'].'-'.'180x60'.'.'.$names['extension'];
//Prints => http://captoons2.se7enmarketing.com/wp-content/uploads/2014/06/eden-apple-180x60.jpg

?>

Here's a demo

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top