note 106804 modified in function.preg-match by danbrown

From: Date: Sun, 11 Dec 2011 19:14:25 +0000
Subject: note 106804 modified in function.preg-match by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185039@lists.php.net to get a copy of this message
Workaround for getting the offset in UTF-8 (in some cases mb_strpos might be an option as well) <?php if(preg_match($pattern,$haystack,$out,PREG_OFFSET_CAPTURE)) { $offset = strlen(utf8_decode(substr($haystack,0,$out[0][1]))); } ?> --was-- // Workaround for getting the offset in UTF-8 // (in some cases mb_strpos might be an option as well) if(preg_match($pattern,$haystack,$out,PREG_OFFSET_CAPTURE)) { $offset = strlen(utf8_decode(substr($haystack,0,$out[0][1]))); } http://php.net/manual/en/function.preg-match.php

« previous php.notes (#185039) next »