TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Wrong output (http://www.talkphp.com/absolute-beginners/4423-wrong-output.html)

9three 05-22-2009 03:30 AM

Wrong output
 
Hey,

I'm trying to output only whats within the quotes ""

PHP Code:

$this->pc file_get_contents('http://www.url.com'FALSENULL0140);
preg_match('~currentPage="(.+?)"~is'$this->pc$this->pc_start);
$PcStart str_replace('~currentPage="(.+?)"~is''(.+?)'$this->pc_start[0]);
    
echo 
$PcStart

When I echo it, it shows currentPage="1". It should only show the integer(int can be anywhere from 1 - 4,000). I'm not good with reg ex though.

Any help? thanks :)

Salathe 05-22-2009 08:54 AM

Here's a little comparison. It grabs the remote file and echoes the value from currentPage="value".


PHP Code:

$html file_get_contents('http://www.url.com'FALSENULL0140);

if (
preg_match('/\bcurrentPage="(.+?)"/i'$html$matches))
{
    echo 
$matches[1];
}
else
{
    echo 
'No currentPage found.';




All times are GMT. The time now is 11:34 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0