text
stringlengths
1
254
output
stringlengths
2
255
If the value of pad_length is negative or less than the length of the input string, no padding takes place.
オプションの引数 pad_type には、 STR_PAD_RIGHT, STR_PAD_LEFT, STR_PAD_BOTHを指定可能です。 pad_type が指定されない場合、STR_PAD_RIGHT を仮定します。
$input = "Alien"; print str_pad($input, 10); / / produces "Alien" print str_pad($input, 10, "-=", STR_PAD_LEFT); / / produces "-=-=-Alien "print str_pad($input, 10, "_", STR_PAD_BOTH); / / produces "__Alien___"
pad_length の値が負または入力文字列の長さよ りも短い場合、埋める操作は行われません。
Home
例 1 str_pad() の例
(PHP 3, PHP 4)
(PHP 3, PHP 4)
Unlike the strrpos(), this function can take a full string as the needle parameter and the entire string will be used.
文字列 haystack の中で、 needle が最初に現れた位置を数字で返します。 strrpos() とは異なり、この関数は needle パラメータとして文字列全体をとり、そ の文字列全体が検索対象となります。
Note:
needle が見つからない場合は FALSE を返します。
Here 's how to detect the difference:
注意 "位置0で文字が見つかった"と"文字がみつからなかった"という返り値 は混同しやすいです。これらを区別するには、次のようにします。
If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.
needle が文字列でない場合は数値に 変換されて、その結果が検索対象の文字コードとして適用されます。
The position returned is still relative to the the beginning of haystack.
オプションの offset パラメータにより haystack のどの文字から検索を開始するかを 指定することが可能です。 この場合でも、返される位置は haystack の先頭に 対する相対位置です。
Prev
strrpos(), strrchr(), substr(), stristr(), strstr() も参照下さい。
Prev
(PHP 3, PHP 4)
This function returns the portion of haystack which starts at the last occurrence of needle and goes until the end of haystack.
この関数は、文字列 haystack の中で、 needle が最後に現れた位置から、 haystack の終わりまでを返します。
If needle contains more than one character, the first is used.
needle が見つからない場合は FALSE を返します。
Example 1. strrchr() example
needle が1つ以上の文字を含んでいる 場合は、最初のものが使われます。
See also strchr(), substr(), stristr(), and strstr().
needle が文字列でない場合、それは 整数に変換され、それが検索対象の文字コードとして適用されます。
Home
例 1 strrchr() の例
strpos
strchr(), substr(), stristr(), strstr(). も参照下さい。
(PHP 4)
(PHP 4)
If the multiplier is set to 0, the function will return an empty string.
input_str を multiplier 回を繰り返した文字列を返します。 multiplier は、0より大きい必要があります。
echo str_repeat( "-=", 10);
例 1 str_repeat() の例
See also for, str_pad(), and substr_count().
出力は、"-=-=-=-=-=-=-=-=-=-=" となります。
Home
substr_count() も参照下さい。
(PHP 3 = 3.0.6, PHP 4)
(PHP 3 = 3.0.6, PHP 4)
If you don' t need fancy replacing rules, you should always use this function instead of ereg_replace() or preg_replace().
この関数は、 subject の中の search を全て replace に置換します。技巧的な置換ルールを 必要としない場合、 ereg_replace() または preg_replace() の替わりにこの関数を常用するべき です。
In PHP 4.0.5 and later, every parameter to str_replace() can be an array.
PHP 4.0.5 以降では、 str_replace() への全てのパ ラメータは配列とすることが可能です。
If subject is an array, then the search and replace is performed with every entry of subject, and the return value is an array as well.
subject が配列の場合、 subject の各エントリについて検索と置換が行 われ、返り値は同様に配列となります。
If replace has fewer values than search, then an empty string is used for the rest of replacement values.
search と replace が配列の場合、 str_replace() は各配列から値を一 つとりだし、 subject 上で検索と置換を行うた めに使用します。 replace の値が search よりも少ない場合、置換される値の残 りの部分には空の文字列が使用されます。 search が配列で replace が文字列の場合、この置換文字列が search の各値について使用されます。しかし、 逆は意味がありません。
Example 1. str_replace() example
例 1 str_replace() の例
This function is binary safe.
この関数はバイナリでも使用可能です。
See also ereg_replace(), preg_replace(), and strtr().
str_replace() は PHP 3.0.6 で追加されましたが、 PHP 3.0.8 まではバグがありました。
str_repeat
ereg_replace() 、 preg_replace() 、 strtr() も 参照下さい。
Returns string, reversed.
(PHP 3, PHP 4)
Reversing a string with strrev()
string を逆順にして返します。
Prev
例 1 strrev() で文字列を逆順にする
This function performs the ROT13 encoding on the str argument and returns the resulting string.
(PHP 4 = 4.2.0)
Encoding and decoding are done by the same function, passing an encoded string as argument will return the original version.
この関数は、 str 引数にROT13エンコードを行い、 結果の文字列を返します。ROT13は、各文字をアルファベット順に13文字 シフトさせ、アルファベット以外の文字はそのままとするエンコードを 行います。エンコードとデコードは同じ関数で行われます。引数にエン コードされた文字列が指定された場合には、元の文字列が返されます。
(PHP 3, PHP 4)
(PHP 3, PHP 4)
Note that the needle in this case can only be a single character.
文字列 haystack の中で、 needle が最後に現れた位置を数字で返します。こ の場合、 needle は単一文字でなければならないこ とに注意して下さい。 needle に文字列が指定され た場合、その文字列の最初の文字だけが使われます。
If needle is not found, returns FALSE.
needle が見つからない場合、 FALSE を返します。
Here 's how to detect the difference:
注意 "位置0に文字が見つかった"と"文字が見つからなかった"場合の返り値 は混同しやすいです。この違いを見分ける方法を以下に示します。
If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.
needle が文字列でない場合は数値に変換されて、 その結果が検索対象の文字として適用されます。
Prev
strpos(), strrchr(), substr(), stristr(), strstr() も参照下さい。
One permutation of all possible is created.
(PHP 4 = 4.3.0)
?php $str = 'abcdef'; $shuffled = str_shuffle($str); / / This will print something like: bfdaec print $shuffled;?
str_shuffle() shuffles a string. One permutation of all possible is created.
Prev
例 1 str_shuffle() example
str_word_count
See also shuffle() and rand().
(PHP 3 = 3.0.3, PHP 4)
(PHP 3 = 3.0.3, PHP 4)
The line of code:
str1 の中で全て str2 の中の文字からなる最初のセグメントの 長さを返します。
See also strcspn().
strcspn() も参照下さい。
Returns part of haystack string from the first occurrence of needle to the end of haystack.
(PHP 3, PHP 4)
If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.
haystack の中で needle が 最初に現れる場所から文字列の終わりまでを返します。
For case-insensitive searches, use stristr().
needle が見つからない場合は FALSE を返しま す。
$email = '[email protected]'; $domain = strstr($email, '@'); print $domain; / / prints @example.com
needle が文字列でない場合は整数に変換され、 その値が検索対象の文字コードとして適用されます。
See also ereg(), preg_match(), strchr(), stristr(), strpos(), strrchr(), and substr().
注意 この関数は大文字小文字を区別することに注意して下さい。大文字小文 字を区別しない検索を行う場合は、 stristr() を使 用して下さい。
Home
例 1 strstr() の例
strspn
ereg(), preg_match(), strchr(), stristr(), strpos(), strrchr(), substr() も参照下さい。
(PHP 3, PHP 4)
(PHP 3, PHP 4)
That is, if you have a string like "This is an example string" you could tokenize this string into its individual words by using the space character as the token.
strtok() は文字列をトークンに分割するために使 用されます。"This is an example string" のような文字列がある場合、 空白文字をトークンとして個々の単語にこの文字列を分割することがで きます。
Example 1. strtok() example
例 1 strtok() の例
Note that only the first call to strtok uses the string argument.
strtok は最初のコールの時のみ string 引数を使用することに注意して下さい。 strtok は、文字列のどっkいるのかの情報を保持しているため、 2回目以降のコールではトークンのみを必要とします。 最初からやりなおす場合や新しい文字列をトークンに分割する場合、 初期化するために再度string引数を指定してstrtokをコールします。 文字列は、引数の文字のどれかが見つかったはトークンに分割されます。
To start over, or to tokenize a new string you simply call strtok with the string argument again to initialize it.
空の部分が見つかった場合の動作はPHP 4.1.0で変更されました。古い動 作は、空の文字列を返しますが、新しい、正しい動作は、文字列のその 部分を単に飛ばします。
The string will be tokenized when any one of the characters in the argument are found.
例 2古い strtok() の動作
The old behavior returned an empty string, while the new, correct, behavior simply skips the part of the string:
例 3新しい strtok() の動作
$first_token = strtok( '/ something',' / '); $second_token = strtok(' / '); var_dump ($first_token, $second_token); / * Output: string(0) "" string(9) "something "* /
トークンを"0"にすることもできることにも注意して下さい。 このトークンを条件式で評価した場合、 FALSE となります。
Also be careful that your tokens may be equal to "0".
split() および explode() も 参照下さい。
Returns string with all alphabetic characters converted to lowercase.
(PHP 3, PHP 4)
This means that in i.e. the default "C" locale, characters such as umlaut-A (Ä) will not be converted.
string のアルファベット部分を すべて小文字にして返します。
$str = "Mary Had A Little Lamb and She LOVED It So"; $str = strtolower($str); print $str; # Prints mary had a little lamb and she loved it so
「アルファベット部分」は現在のロケールにより決定されます。 このため、たとえばデフォルトの "C" ロケールである場合は、 ウムラウトA (Ä) のような文字は変換されません。
Prev
例 1 strtolower() の例
strtoupper
strtoupper(), ucfirst(), ucwords() も参照下さい。
Prev
(PHP 3 = 3.0.12, PHP 4)
The function expects to be given a string containing an English date format and will try to parse that format into a UNIX timestamp relative to the timestamp given in now, or the current time if none is supplied.
この関数は英文形式の日付を含む文字列が指定されることを期待してお り、その形式からUNIXタイムスタンプへの変換を試みます。
Because strtotime() behaves according to GNU date syntax, have a look at the GNU manual page titled Date Input Formats.
例 1 strtotime() の例
Example 1. strtotime() examples
例 2失敗のチェック
$str = 'Not Good'; if (($timestamp = strtotime($str)) === -1) {echo "The string ($str) is bogus";} else {echo "$str == ". date('l dS of F Y h:i:s A',$timestamp);}
注意 タイムスタンプの有効な範囲は、通常、Fri, 13 Dec 1901 20:45:54 GMTからTue, 19 Jan 2038 03:14:07 GMTまでです。(これらは、32ビッ ト符号付整数の最大及び最小に一致します。)
Returns string with all alphabetic characters converted to uppercase.
(PHP 3, PHP 4)
For instance, in the default "C" locale characters such as umlaut-a (ä) will not be converted.
string のアルファベット部分を すべて大文字にして返します。
$str = "Mary Had A Little Lamb and She LOVED It So"; $str = strtoupper($str); print $str; # Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
「アルファベット部分」は現在のロケールにより決定されます。 つまり、たとえばデフォルトの "C" ロケールである場合は、 ウムラウトa (ä)のような文字は変換されません。
Prev
例 1 strtoupper() の例
strtolower
strtolower(), ucfirst(), ucwords() も参照下さい。
Prev
(PHP 3, PHP 4)
This function returns a copy of str, translating all occurrences of each character in from to the corresponding character in to and returning the result.
この関数は str を走査し、 from に含まれる文字が見つかると、そのすべてを to の中で対応する文字に置き換え、 その結果を返します。
Example 1. strtr() example
from と to の 長さが異なる場合、長い方の余分な文字は無視されます。
$addr = strtr( $addr, "äåö", "aao");
例 1 strtr() の例
Examples:
例:
Note:
注意 このオプションのパラメータ to および from は、PHP 4.0.0 で追加されました。
See also ereg_replace().
ereg_replace() も参照下さい。
(PHP 3, PHP 4)
(PHP 3, PHP 4)
See the documentation on string for more information on converting to string.
var の string としての値を返しま す。文字列への変換の詳細については、 string のドキュメ ントを参照下さい。
You cannot use strval() on arrays or objects.
var は、全てのスカラー値にできます。 strval() に配列又はオブジェクトは使用可能できま せん。
Prev
floatval(), intval(), settype(), 型の相互変換(ジャグリング) を参照下さい。
Counts the number of words inside string.
(PHP 4 = 4.3.0)
The possible value for the format and the resultant outputs are listed below.
1 - returns an array containing all the words found inside the string.
2 - returns an associative array, where the key is the numeric position of the word inside the string and the value is the actual word itself.
2 - returns an associative array, where the key is the numeric position of the word inside the string and the value is the actual word itself.
Prev
For the purpose of this function, 'word' is defined as a locale dependent string containing alphabetic characters, which also may contain, but not start with "'"and "-" characters.
(PHP 4)
(PHP 4)
Example 1. substr_count() example
substr_count() は、文字列 haystack の中での副文字列 needle の出現回数を返します。
See also count_chars(), strpos(), substr(), and strstr().
例 1 substr_count() の例
Prev
(PHP 3, PHP 4)
substr() returns the portion of string specified by the start and length parameters.
substr() は文字列 string の、 start で指定された 位置から length バイト分の文字列を 返します。