note 40609 modified in function.substr by aidan

From: Date: Sat, 03 Jul 2004 07:43:38 +0000
Subject: note 40609 modified in function.substr by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-72364@lists.php.net to get a copy of this message
For those who want to SJIS (Japanese Encoding), this function can be used. This function is based on the function of Windix for UTF-8 users. This function was very helpful for me. Thank you, Windix! <?php function sjis_substr($str,$start) { preg_match_all( "/[\x81-\x9f][\x40-\xfc]|[\xe0-\xfc] [\x40-\xfc]|[\xa1-\xdf]|[\x01-\x7f]/", $str, $ar); if(func_num_args() >= 3) { $end = func_get_arg(2); return join("",array_slice($ar[0],$start,$end)); } else { return join("",array_slice($ar[0],$start)); } return $str; } ?> --was-- For those who want to SJIS (Japanese Encoding), this function can be used. This function is based on the function of Windix for UTF-8 users. This function was very helpful for me. Thank you, Windix! function sjis_substr($str,$start) { preg_match_all( "/[\x81-\x9f][\x40-\xfc]|[\xe0-\xfc] [\x40-\xfc]|[\xa1-\xdf]|[\x01-\x7f]/", $str, $ar); if(func_num_args() >= 3) { $end = func_get_arg(2); return join("",array_slice($ar[0],$start,$end)); } else { return join("",array_slice($ar[0],$start)); } return $str; } http://php.net/manual/en/function.substr.php

« previous php.notes (#72364) next »