Solved:Help for a function get_img_basic

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gosu
Forum Newbie
Posts: 19
Joined: Mon Jun 02, 2008 12:17 pm

Solved:Help for a function get_img_basic

Post by gosu »

Edit: I found error in the script, this works fine ;)

The function returns the link of the image when it sees <img src=""> (i think)
It works fine when there is a text with image src tag but...
I need to make it work for:

<img src=\"".$config['http_home_url']."uploads/".$modul_filesdir."/{$cat_i_down[$row['category']]['dir']}/thumbs/{$row['screenshot']}\">

Any help is greatly appriciated!

The function:

Code: Select all

function get_img_basic($text){
    preg_match('|<img(.*) src="([^"]*)"[^>]*>|is', $text, $out); 
    return $out[2];
};
The working result should be looking like this:

Code: Select all

 $img =  get_img_basic("<img src=\"".$config['http_home_url']."uploads/".$modul_filesdir."/{$cat_i_down[$row['category']]['dir']}/thumbs/{$row['screenshot']}\">");
 
Post Reply