Grabeorama Posted March 21, 2010 Share Posted March 21, 2010 I have a form that sends data to the database. It aks the user to the url of different images on a separate line of the textbox.So the information would look something like this:http://www.web.com/image.jpghttp://www.web.com/image2.jpghttp://www.web.com/image3.jpgI'd like to display this information as separate images so I would need something like1. Find out how many urls were submitted, maybe using subtr_count($string,"\n")2. Copy each url3. Get rid of the "\n" in each case.4. Put each url: <img src="{here}">I don't know how to do steps two, three or four any ideas?Thanks Link to comment Share on other sites More sharing options...
jeffman Posted March 21, 2010 Share Posted March 21, 2010 Have a look at preg_split. A good regex could remove any possible combination of newline characters (including multiples, as when a user hits the return key twice) and leave you with an array of urls. Example #1 on that page comes very close to what you want.With a unique url in an array element, you'd construct your tag something like this:$myTag = "<img src='{$arr[0]}'>";The braces are correct for interpolating array values, BTW. Link to comment Share on other sites More sharing options...
Grabeorama Posted March 21, 2010 Author Share Posted March 21, 2010 After a bit of fiddling and testing I got it working, thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.