note 42821 deleted from function.strpos by tomsommer

From: Date: Mon, 31 May 2004 00:19:04 +0000
Subject: note 42821 deleted from function.strpos by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-70323@lists.php.net to get a copy of this message
Note Submitter: Niklas Håkansson ---- Just started to use PHP and find it quite fun to use....When I was converting a Javascript I missed the indexOf function so I created one myselft which works just fine. function indexOf($str,$strChar) { if(strlen(strchr($str,$strChar))>0) { $position_num = strpos($str,$strChar); return $position_num; } else { return -1; } } One way to use it: $temp = "bla bla bla hepp bla bla hepp"; if(indexOf($temp,"hepp")>-1) { echo indexOf($temp,"hepp"); } And it works just like this javascript: <script language="javascript"> var temp = "bla bla bla hepp bla bla hepp"; if(temp.indexOf("hepp")>-1) { alert(temp.indexOf("hepp")); } </script>

« previous php.notes (#70323) next »