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