1
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 substr()の引数について

Posted at

#引数についての考察

substr

例)


var_dump(substr('abcdef', 0, 4)); // "abcd"
var_dump(substr('abcdef', -3, 1)); // "d"
var_dump(substr('abcdef', -3, -1)); // "de"
var_dump(substr('abcdef', -3, -2)); // "d"
var_dump(substr('abcdef', -3, -3)); // ""
  • 第一引数:対象文字列
  • 第二引数:ポインタの位置
  • 第三引数:ポインタから正の方向にn文字 or 文末から負の方向に移動し、オフセットから負の方向に移動した分を除いた文字を表示

第三引数が難しい印象だ

1
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
1
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?