note 94652 modified in function.explode by felipe

From: Date: Fri, 20 Nov 2009 00:54:43 +0000
Subject: note 94652 modified in function.explode by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-163118@lists.php.net to get a copy of this message
when the encoding of $string is 'GBK' and $delimiter is '|' , the return value may be wrong. for example: <?php $result = explode("|", "滕华弢|海青"); var_dump($result); ?> and the result will be: array ( 0 => '滕华, 1 => '', 2 => '海青', ) bcz "弢" 's GBK is '0x8f7c'. and "|" 's ASCII is '0x7c'. So, all GBK-encoding characters include '7c' will lead to the error result. --was-- when the encoding of $string is 'GBK' and $delimiter is '|' , the return value may be wrong. for example: $result = explode("|", "滕华弢|海青"); var_dump($result); and the result will be: array ( 0 => '滕华, 1 => '', 2 => '海青', ) bcz "弢" 's GBK is '0x8f7c'. and "|" 's ASCII is '0x7c'. So, all GBK-encoding characters include '7c' will lead to the error result. http://php.net/manual/en/function.explode.php

« previous php.notes (#163118) next »