UnknownPlayer Posted May 8, 2011 Share Posted May 8, 2011 I have this code, but it doesn't work: $input = "http://loombo.com/tg6nuw42yahw"; $search = "/http:\/\/(?:www\.)?loombo\.com\/(.*?)/is"; $replace = "<iframe style='overflow: hidden; border: 0; width: 500px; height: 351px;' src='http://loombo.com/embed-$1-500x316.html' scrolling='no'></iframe>"; echo preg_replace($search,$replace,$input); Now this address in iframe should be: http://loombo.com/embed-tg6nuw42yahw-500x316.html, but it isn't. When i look at souce code of page, address in that iframe is http://loombo.com/embed-[empty]-500x316.html Can someone help me? Link to comment https://forums.phpfreaks.com/topic/235837-preg_replace-help/ Share on other sites More sharing options...
.josh Posted May 8, 2011 Share Posted May 8, 2011 need to change (.*?) to (.*) Since .*? is a lazy match, and since it is the last thing in the string to match, it fulfills the pattern by matching nothing. Link to comment https://forums.phpfreaks.com/topic/235837-preg_replace-help/#findComment-1212403 Share on other sites More sharing options...
UnknownPlayer Posted May 8, 2011 Author Share Posted May 8, 2011 Thanks, it works.. I had this example in other script, and it worked, but now in this exmaple it doesn't work.. Thanks again.. Link to comment https://forums.phpfreaks.com/topic/235837-preg_replace-help/#findComment-1212466 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.