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? Quote Link to comment 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. Quote Link to comment 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.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.