Page 1 of 1

please help with preg_match

Posted: Sun Feb 13, 2011 3:54 pm
by robertbarzyk
This is the string im looking for in this example
[text]<img src="http://c3.ac-images.myspacecdn.com/imag ... 6d9932.jpg" class="profilePic" alt="Photo of ıł♥νeчøυ(:" />[/text]

I NEED to use preg_match for this...
The img src will be different everytime and so will the alt.
here is the code i have so far but i cant seem to get it right... the only piece of info i need out of the string above is the img src
but once again... i need to find in with preg match in that certain string. please and thanks for any help


$fid = 178902;
$getfid = $fid;
$ip = $_SERVER['REMOTE_ADDR'];

define ("getFID","http://www.myspace.com/" );
$path = getFID.$getfid;
$holdID = file_get_contents($path);

define ("profile_url","http://mx.myspace.com/" );
$full_file_path = profile_url.$fid;
$handle = fopen("http://myspace.com/$fid","r");
if (!$handle){
echo "<p>Sorry Myspace Is Slow Try Again.\n";
$arr = 0; }
else {
$timeout = 300;
ini_set('max_execution_time','120');
set_time_limit(120);
ini_set('default_socket_timeout','120');
while($contents = fread($handle,'1024'))
{ $hold .= $contents; }


preg_match("<img src=\"([^\">]+)\" class=\"profilePic\" alt=\".*?\" />",$hold,$match);

Re: please help with preg_match

Posted: Sun Feb 13, 2011 7:38 pm
by gooney0
You may have more luck in the regex forum:

viewforum.php?f=38

I often cheat and use str_pos and str_len to do this sort of work.