Help - Search - Members - Calendar
Full Version: Not so effecient?
Invision Power Services > Community Forums > Community Web Design and Coding
Kenny Pollock
I'm using JavaScript to fill out a form with a car's year, make and model after they enter a VIN number.
I came up with:
CODE
$url = file_get_contents( 'http://www.carfax.com/cfm/check_order.cfm?vin=' . $_GET['vin'] . '&partner=UNK_1_DEC_31&zipcode=&ClickID=&SiteID=&suggest=N&FID=&PopUpStatus=0' );

$array = explode( '<b>Year/Make/Model:</b>', $url );

$array2 = explode( '<b>Manu', $array[1] );

$replace = array( '<font face="Courier New, Courier, mono" size="2">', '<tr>', '<td align="left" valign="middle">', '</td>', '</font>', '<td width="150" align="left" valign="middle">', '<tr bgcolor="#E3E3E3">' );

$replaced = str_replace( $replace, '', $array2[0] );

$break = explode( '</tr>', $replaced );

echo trim( $break[0] );

I was wondering, is there a more effecient way to doing this? I'm thinking using preg_replace or something I could get just what I need, instead of stripping everything I don't..but I'm not too familiar with this.
_
In PHP I've found that 4-5 explodes commonly will be faster than a single regexp, so most likely you're best off doing what you do now. I don't know if I'd use file_get_contents however, since it's pretty slow; maybe you should consider cURL (has better support for many things, including gzip, making it faster).
Brendon Koz
Since you suggest cURL, know of any DECENT online tutorials (beginning to advanced) out there? I can't figure out how to get it to work. sad.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.