brosjr Posted July 1, 2011 Share Posted July 1, 2011 Hi everyone, I'm writing a script that uses CURL to capture some data to analise it. While this I have to find a little part of a string in many other strings from an array, so I'm using srtpos, but it's returning strange values. For exemple, when I use the string, like below, it echos "9", and it's ok. $strarray = 'SD55555 |FIL|END|'; $find = 'FIL'; $pos = strpos($strarray , $find); echo $pos; But when I use the same estructure to find the same thing from the array, where $arrayhist[1] = 'SD55555 |FIL|END|', it returns nothing. $strarray = $arrayhist[1]; $find = 'FIL'; $pos = strpos($strarray , $find); echo $pos; Even strange, if instead of 'FIL' I try to find 'SD' it returns "0". And if I try to find just 'D' it also returns nothing. Some clue? :-\ Thankx Danilo Jr. Link to comment https://forums.phpfreaks.com/topic/240902-srtpos/ Share on other sites More sharing options...
EdwinPaul Posted July 1, 2011 Share Posted July 1, 2011 This works: $strarray = 'SD55555 |FIL|END|'; $find = 'FIL'; $pos = strpos($strarray , $find); echo $pos.'<br/>'; $arrayhist=array('','SD55555 |FIL|END|',''); // first element = $arrayhist[0], second element = $arrayhist[1] $strarray = $arrayhist[1]; echo $strarray.'<br/>'; $find = 'FIL'; $pos = strpos($strarray , $find); echo $pos; Link to comment https://forums.phpfreaks.com/topic/240902-srtpos/#findComment-1237463 Share on other sites More sharing options...
.josh Posted July 1, 2011 Share Posted July 1, 2011 $strarray = $arrayhist[1]; echo $strarray; // does this have the expected value? Link to comment https://forums.phpfreaks.com/topic/240902-srtpos/#findComment-1237465 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.