470,848 Members | 1,321 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

Search for string and then take string next to it.

Hi,

What I'm looking for is a way for php to retrieve a webpage, search for a
string in it, and next to that will be a date string in the format (e.g.)
03-Sep-04 22:37:40 BST, and then I'd like PHP to store that as a date/time
variable (preferably using unix timestamp)...

This possible?

Thanks,

Ben
--
BWGames
to email change de.news to de-news
Jul 17 '05 #1
5 1634
On Mon, 1 Nov 2004 08:14:58 +0000, BWGames wrote:
Hi,

What I'm looking for is a way for php to retrieve a webpage, search for a
string in it, and next to that will be a date string in the format (e.g.)
03-Sep-04 22:37:40 BST, and then I'd like PHP to store that as a date/time
variable (preferably using unix timestamp)...

This possible?

Thanks,

Ben


Also, the timezone is irrelevant, I just need a way of identifying dd-mm-yy
hh:mm:ss as a php date/time stamp to perform time calculations on it...
--
BWGames
to email change de.news to de-news
Jul 17 '05 #2
On Mon, 01 Nov 2004 08:14:58 +0000, BWGames wrote:
What I'm looking for is a way for php to retrieve a webpage, search for a
string in it, and next to that will be a date string in the format (e.g.)
03-Sep-04 22:37:40 BST, and then I'd like PHP to store that as a date/time
variable (preferably using unix timestamp)...

This possible?


http://www.php.net/strtotime

Adam

--
Adam Harvey
Optimiser Pty Ltd

To e-mail: don't make an example out of me!

Jul 17 '05 #3
On Mon, 01 Nov 2004 16:29:35 +0800, Adam Harvey wrote:
On Mon, 01 Nov 2004 08:14:58 +0000, BWGames wrote:
What I'm looking for is a way for php to retrieve a webpage, search for a
string in it, and next to that will be a date string in the format (e.g.)
03-Sep-04 22:37:40 BST, and then I'd like PHP to store that as a date/time
variable (preferably using unix timestamp)...

This possible?


http://www.php.net/strtotime

Adam


Thanks!

I now need to search for a string and return the next X characters to
it....

I'm guessing I'd use libcurl or similar to retrieve the webpage, and them
do strpos to find the string, but how to get the characters next to it?

I'm looking at
between... sometihng like between
between ('string1', 'string after what i want',$retrievedpage);

then strtotime...
That the best way?

Thanks,
ben
--
BWGames
to email change de.news to de-news
Jul 17 '05 #4
BWGames wrote:
I now need to search for a string and return the next X characters to
it.... [snip] I'm looking at
between... sometihng like between
between ('string1', 'string after what i want',$retrievedpage);

<?php
function text_after($haystack, $needle, $size) {
$pos = strpos($haystack, $needle);
if ($pos === false) return false;
return substr($haystack, $pos+strlen($needle), $size);
}

$text = 'one two three four five six seven';

$found = text_after('three', 5, $text);
if ($found === false) echo "Not found\n";
else echo 'Found: ', $found, "\n";
?>
--
USENET would be a better place if everybody read: | to mail me: simply |
http://www.catb.org/~esr/faqs/smart-questions.html | "reply" to this post, |
http://www.netmeister.org/news/learn2quote2.html | *NO* MIME, plain text |
http://www.expita.com/nomime.html | and *NO* attachments. |
Jul 17 '05 #5
Pedro Graca wrote:
<?php
function text_after($haystack, $needle, $size) {
$pos = strpos($haystack, $needle);
if ($pos === false) return false;
return substr($haystack, $pos+strlen($needle), $size);
}

$text = 'one two three four five six seven';

$found = text_after('three', 5, $text);
Oops, this last line should have been

$found = text_after($text, 'three', 5);
if ($found === false) echo "Not found\n";
else echo 'Found: ', $found, "\n";
?>

--
USENET would be a better place if everybody read: | to mail me: simply |
http://www.catb.org/~esr/faqs/smart-questions.html | "reply" to this post, |
http://www.netmeister.org/news/learn2quote2.html | *NO* MIME, plain text |
http://www.expita.com/nomime.html | and *NO* attachments. |
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Lee Mundie | last post: by
reply views Thread by todd | last post: by
32 posts views Thread by tshad | last post: by
1 post views Thread by Eric | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.