stripos()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
navid
Forum Commoner
Posts: 68
Joined: Tue Sep 24, 2002 3:14 am
Location: iran

stripos()

Post by navid »

hi dear
I will know about stripos()
I know , how to use stripos() function in to the php4.2.3?
please help me
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

[php_man]stripos[/php_man]
navid
Forum Commoner
Posts: 68
Joined: Tue Sep 24, 2002 3:14 am
Location: iran

Post by navid »

hi Weirdan
thanks

I read it .
but i will use this function in to the php version 4.2.3
if u know please help me
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Have a look at the first user comment at http://php.net/stripos
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

quick and simple quesiton : why haven't you upgraded? :P
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

infolock wrote:quick and simple quesiton : why haven't you upgraded? :P
stripos is only available in PHP5. As PHP5 is still in RC status then there is no point in upgrading to PHP5 if you distribute your apps/scripts to the mass public.

I would be very surprised if you found PHP5 installed on a production server at present and even when PHP5 reaches stable release status it will not make it onto production servers over night.

Here is my stripos function....

Code: Select all

<?php
if (!function_exists('stripos'))
{
  function stripos($haystack, $needle, $offset = 0)
  {
    $temp = substr($haystack, $offset);
    $temp = stristr($temp, $needle);
    $pos = $temp !== false ? strlen($haystack)-strlen($temp) : false;
    return $pos;
  }
}
?>
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

why not just:

Code: Select all

if (!function_exists('stripos'))
{
  function stripos($haystack, $needle, $offset = 0)
  {
      return strpos(strtolower($haystack), strtolower($needle), $offset);
  }
}
??
Post Reply