Jump to content


- - - - -

RESOLVED: ereg help needed


  • Please log in to reply
3 replies to this topic

#1 Maynard

Maynard

    Coder

  • Members
  • PipPipPipPipPip
  • 108 posts
  • Location:Finland
  • Real Name:Jarmo
  • IPB Version:v3.2.x

Posted 26 March 2010 - 07:33 PM

We've been using the below code to create imdb links from film names stored in database. Now imdb has made changes and they no longer work. For example if film name is Film Name (2009) the link to imdb gets is
http://www.imdb.com/find?s=tt&q=Film%2520Name
. I need modify the ereg so that it replaces the %2520s in search url with a '+' signs.

<tr><td width="20%" class="datacell">IMDb:</td><td width="70%" class="datacell"><a href="http://us.imdb.com/find?s=tt&q=<?php

if (ereg ("(.*) \(([0-9]{4})\)", $movie[film_name], $regs)) {
   echo "$regs[1]";
} else {
   echo $movie[film_name];
}

?>" target="_blank">IMDb</a></td></tr>

Edited by Maynard, 26 March 2010 - 07:34 PM.


#2 Martin

Martin

    But but, it's not only only!

  • Management
  • PipPipPipPipPipPipPipPipPipPip
  • 7,081 posts
  • Location:Hammerfest, Norway
  • Real Name:Martin Aronsen
  • IPB Version:v3.2.x
Contributor

Posted 27 March 2010 - 12:45 AM

Try
echo str_replace(' ', '+', $regs[1] );


#3 Maynard

Maynard

    Coder

  • Members
  • PipPipPipPipPip
  • 108 posts
  • Location:Finland
  • Real Name:Jarmo
  • IPB Version:v3.2.x

Posted 27 March 2010 - 01:21 AM

It works. Thnx ;)

#4 riven3d

riven3d

    Needs to get out more

  • Support Staff
  • PipPipPipPipPipPipPipPipPipPip
  • 3,908 posts
  • Location:Florida
  • Real Name:Michael
  • IPB Version:v3.1.x
Contributor

Posted 27 March 2010 - 01:29 AM

The issue this topic was opened for has now been resolved. ;)

Did you find my support helpful? Feel free to donate!
Posted Image





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users