0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PHP strcmp()使い方

Last updated at Posted at 2021-03-12

第一引数の文字が第二引数の文字と比べどの位置にあるか

ドキュメントには
https://www.php.net/manual/ja/function.strcmp.php
strcmp — バイナリセーフな文字列比較
この比較は大文字小文字を区別することに注意してください。

str1 が str2 よりも小さければ < 0 を、str1が str2よりも大きければ > 0 を、 等しければ 0 を返します。```

とある

例)

```php

echo strcmp("a", "b"); //-1
echo strcmp("a", "c"); //-2
echo strcmp("c", "a"); //2
echo strcmp("あ", "a"); //130
echo strcmp("x51", "x52"); //-1

上記の結果を得られる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?