note 95110 deleted from function.stripos by danbrown

From: Date: Mon, 14 Dec 2009 15:59:44 +0000
Subject: note 95110 deleted from function.stripos by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-163938@lists.php.net to get a copy of this message
Note Submitter: Klark ---- I just want to correct my previous statement about the multi-byte character encoding support. It won't work if the searched string isn't at the position 0. <?php $unicode_string = '¡¤Æ‰æ« “‹‘’›”ϡϿӉԅש؁ضܓܛߨ◎✂➷Ⱡ—test» —–¾½¬ß¹²³´'; $search_for = 'ϡϿӉԅש؁ضܓܛߨ◎✂➷Ⱡ—test'; $position = stripos($unicode_string, $search_for); $position_mb = mb_stripos($unicode_string, $search_for, 0, "UTF-8"); if ($position !== false) { echo "Found using stripos on position $position! \n"; } if ($position_mb !== false) { echo "Found using mb_stripos on position $position_mb!"; } /* Output: Found using stripos on position 32! Found using mb_stripos on position 13! */ ?> See the difference? :p Use mb_stripos() to have an accurate position with Unicode UTF-8 strings.

« previous php.notes (#163938) next »