Jump to content

srtpos?


brosjr

Recommended Posts

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

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

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.