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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.