<?php
$url = 'www.somesite/somepage';
$raw = file_get_contents($url);
preg_match('/\w(\d*).*?\$/',$raw,$matches);
echo $matches;
?>
this is what I tried for now
I just get "array" printed
in a given external website I need the closest number to the first appearance of the symbol $
finding number colse to the symbol
Moderator: General Moderators
-
avukadomusic
- Forum Newbie
- Posts: 6
- Joined: Fri Jun 12, 2009 3:20 am
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
-
avukadomusic
- Forum Newbie
- Posts: 6
- Joined: Fri Jun 12, 2009 3:20 am
Re: finding number colse to the symbol
it seems like print_r is not a known php word
I get error unexpected T_VARIABLE for this
if you meant print_r () I tried it and got nothing
print_r ($matches);
I also tried regular print with result just like echo
I tried addind [0] or [1] for $matches
then I get nothing
I get error unexpected T_VARIABLE for this
if you meant print_r () I tried it and got nothing
print_r ($matches);
I also tried regular print with result just like echo
I tried addind [0] or [1] for $matches
then I get nothing
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: finding number colse to the symbol
mea culpa, I meant print_r()avukadomusic wrote:it seems like print_r is not a known php word
I get error unexpected T_VARIABLE for this
if you meant print_r () I tried it and got nothing
print_r ($matches);
At the very least, this should display an empty array.
If you're getting absolutely nothing displayed when you print_r($matches), then the problem is probably in your regular expression
-
avukadomusic
- Forum Newbie
- Posts: 6
- Joined: Fri Jun 12, 2009 3:20 am
Re: finding number colse to the symbol
my regular expression is what I wrote above
why doesnt it work?
why doesnt it work?
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: finding number colse to the symbol
Passavukadomusic wrote:my regular expression is what I wrote above
why doesnt it work?
Knowing the type of data in $raw that you are parsing might help