# \[php\] strpos and substr

**URL:** <https://forum.kirupa.com/t/php-strpos-and-substr/147799>\
**Category:** Uncategorized\
**Created:** [May 13, 2005, 7:40pm UTC](https://forum.kirupa.com/t/php-strpos-and-substr/147799 "2005-05-13T19:40:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hl1](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/hl1/32/849_2.png) [@hl1](https://forum.kirupa.com/u/hl1)\
**Post date:** [May 13, 2005, 7:40pm UTC](https://forum.kirupa.com/t/php-strpos-and-substr/147799/1 "2005-05-13T19:40:19Z")

</div>

```php

<?
$fp = fopen("http://www.weather.com/weather/local/" . $_GET['zip'], r);
$startpos = strpos($fp, "<B CLASS=obsTempTextA>");
$endpos = strpos($fp, "</B>", $startpos);
$temp = substr($fp, $startpos[0], $endpos[0]);
fclose($fp);
print($temp)
?>

```

What is wrong with this code?! I’m puzzled… no PHP error, just doesn’t print anything.  
Basically the script gets the temperature from [weather.com](http://weather.com) according to a zip code the user inputs…  
[www.weather.com/weather/local/21044](http://www.weather.com/weather/local/21044)  
[http://www.dotlall.com/weather-test.php?zip=21044](http://www.dotlall.com/weather-test.php?zip=21044)

help!
