downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

iconv> <iconv_strrpos
Last updated: Fri, 06 Nov 2009

view this page in

iconv_substr

(PHP 5)

iconv_substr文字列の一部を切り出す

説明

string iconv_substr ( string $str , int $offset [, int $length = 0 [, string $charset = ini_set("iconv.internal_encoding") ]] )

文字列 str の、 startlength で指定された一部を返します。

パラメータ

str

元の文字列。

offset

start が負でない場合、 iconv_substr()strstart 番目の文字(ゼロから数えて)から切り出します。

start が負の場合、 iconv_substr()str の最後から数えて start 番目の文字から切り出します。

length

length が指定され、かつ正である場合、 返される文字列は start から数えて最大 length 文字数分となります (string の長さに依存します)。

もし負の length が渡された場合に iconv_substr() が切り出す文字列は、 strstart 番目の文字からはじまり、文字列の最後から数えて length 文字分戻ったところまでとなります。 start も負の場合、開始位置は 上で説明した方式で計算されます。

charset

charset が指定されなかった場合、文字セットは ini 設定 iconv.internal_encoding で定義された値とみなされます。

offsetlength のパラメータは、常に charset で定義された 文字セットにおける文字数と判断されることに注意してください。 一方、substr() の場合はこれらの値を常に バイト数として判断します。

返り値

文字列 str の、 offsetlength で指定された一部を返します。

もし strstart の文字列長より短い場合は、FALSE が返されます。

参考



add a note add a note User Contributed Notes
iconv_substr
qbolec at terra dot es
25-May-2007 09:07
<?=
iconv_substr
("A",0,1);
?>
generates folowing error:
Notice: iconv_substr() [function.iconv-substr]: Unknown error (0) in [...]

while, <?= iconv_substr("AB",0,1) ?> and <?= iconv_substr("AB",0,2) ?>
work as expected.

iconv> <iconv_strrpos
Last updated: Fri, 06 Nov 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites