Jump to content

Finding a phrase


papaface

Recommended Posts

Hello,
I was wondering if someone can show me how (or point me in the right direction) I would:

[code]$file = file_get_contents("someurl.com")or die ("error " . mysql_error());
echo $file;[/code]

^^ use that code, and then ask php to find a particular phrase in the contents of the url, for instance: "Item price: $21" and then echo it out to the browser.
Note: the value of item total would change quite frequently, so i need a way of getting "Item price: something".

Thanks.
Link to comment
https://forums.phpfreaks.com/topic/30499-finding-a-phrase/
Share on other sites

Try this, and if it doesn't work, than can you show the code that is in the file your retrieving?
[CODE]<?php

$file = file_get_contents("someurl.com")or die ("error " . mysql_error());
echo $file;
preg_match_all("~^[a-zA-Z]: \$[0-9]$/i~", $file,$out, PREG_PATTERN_ORDER);
foreach($out[0] as $value){
    echo $value.'<br>';
}[/CODE]
Link to comment
https://forums.phpfreaks.com/topic/30499-finding-a-phrase/#findComment-140436
Share on other sites

[code]<?php

$file = file_get_contents("http://www.amazon.co.uk/Sony-Ericsson-W800i-Vodafone-Weekends/dp/B000BSRU6I")or die ("error " . mysql_error());
echo $file;
preg_match_all("~^Price: \£[0-9]$/i~", $file,$out, PREG_PATTERN_ORDER);
foreach($out[0] as $value){
    echo $value.'<br>';
}
?>
[/code]
That is what im using. Its not the URL im really trying to use, but it still doesnt work.
Link to comment
https://forums.phpfreaks.com/topic/30499-finding-a-phrase/#findComment-140444
Share on other sites

Its good for that website. But as I mentioned the link I gave you isnt the link I want to use. The link I want to use is for something completely different. I basically need the ability to enter a phrase and for php to bring back the phrase then the number to the right of it, whether it be a currency or just a number. Do you have any other method of contact besides the forum The Little Guy ?
Link to comment
https://forums.phpfreaks.com/topic/30499-finding-a-phrase/#findComment-140553
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.