★ wanayoo — archive 1999 http://fr.php.net/manual/ja/function.substr.phpNouvelle recherche | Portail wanayoo
PHP Tuesday, March 20, 2001  
downloads | documentation | faq | support | reporting bugs | links 

search for in the  

lookup:
PHP マニュアルPHP マニュアル
文字列文字列
 AddCSlashesAddCSlashes
 AddSlashesAddSlashes
 bin2hexbin2hex
 ChopChop
 ChrChr
 chunk_splitchunk_split
 convert_cyr_stringconvert_cyr_string
 count_charscount_chars
 crc32crc32
 cryptcrypt
 echoecho
 explodeexplode
 get_html_translation_tableget_html_translation_table
 get_meta_tagsget_meta_tags
 hebrevhebrev
 hebrevchebrevc
 htmlentitieshtmlentities
 htmlspecialcharshtmlspecialchars
 iconviconv
 implodeimplode
 joinjoin
 levenshteinlevenshtein
 localeconvlocaleconv
 ltrimltrim
 md5md5
 MetaphoneMetaphone
 nl2brnl2br
 OrdOrd
 parse_strparse_str
 printprint
 printfprintf
 quoted_printable_decodequoted_printable_decode
 QuoteMetaQuoteMeta
 rtrimrtrim
 sscanfsscanf
 setlocalesetlocale
 similar_textsimilar_text
 soundexsoundex
 sprintfsprintf
 strncasecmpstrncasecmp
 strcasecmpstrcasecmp
 strchrstrchr
 strcmpstrcmp
 strcollstrcoll
 strcspnstrcspn
 strip_tagsstrip_tags
 StripCSlashesStripCSlashes
 StripSlashesStripSlashes
 stristrstristr
 strlenstrlen
 strnatcmpstrnatcmp
 strnatcasecmpstrnatcasecmp
 strncmpstrncmp
 str_padstr_pad
 strposstrpos
 strrchrstrrchr
 str_repeatstr_repeat
 strrevstrrev
 strrposstrrpos
 strspnstrspn
 strstrstrstr
 strtokstrtok
 strtolowerstrtolower
 strtoupperstrtoupper
 str_replacestr_replace
 strtrstrtr
 substrsubstr
 substr_countsubstr_count
 substr_replacesubstr_replace
 trimtrim
 ucfirstucfirst
 ucwordsucwords
 wordwrapwordwrap

previousstrtr
substr_countnext

Last updated: Sun, 18 Mar 2001
view this page in English | Brazilian Portuguese | Czech | Dutch | French | German | Hungarian | Italian | Japanese | Korean | Spanish | Plain HTML

substr

(PHP 3, PHP 4 )

substr -- 文字列の一部分を返す

説明

string substr (string string, int start, int [length])

substr() は文字列 string の、start で指定された 位置から length バイト分の文字列を 返します。

start が正の場合、返される文字列は、 string の 0 から数えて start番目から始まる文字列となります。 例えば、文字列'abcdef'において位置 0にある文字は、'a'であり、 位置2には'c'があります。

例:


$rest = substr("abcdef", 1); // "bcdef" を返します
$rest = substr("abcdef", 1, 3); // "bcd" を返します
      

start が負の場合、返される文字列は、 string の 後ろから数えて start番目から始まる文字列となります。 例:


$rest = substr("abcdef", -1); //  "f" を返します
$rest = substr("abcdef", -2); // "ef" を返します
$rest = substr("abcdef", -3, 1); // "d" を返します
      

length が指定され、かつ正である 場合、返される文字列は start から հえて length 文字数分となります。 負の length が指定された場合、(start は文字列の終端を過ぎているので) 返される文字列は start の位置にある 1文字のみとなります。

length が指定され、かつ負である 場合、返される文字列は start の後ろ から数えて length 文字までとなります。 この指定により切り出す文字列の長さが負となる場合、 startの位置にある1文字のみが 文字列として返されます。

例:


$rest = substr("abcdef", 1, -1); // "bcde" を返Wます
      

strrchr() および ereg() も参照下さい。

previousstrtr
substr_countnext

Last updated: Sun, 18 Mar 2001
add note | about notes

show source | credits | mirror sites:  

Copyright © 1998-2001 The PHP Group
All rights reserved.
This mirror generously provided by: L'Université Michel de Montaigne Bordeaux III
Last updated: Tue Mar 20 09:31:23 2001 MET