忍者ブログ

からすまる日誌

文字列の末尾を取得/文字列の末尾を削除(php)

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

文字列の末尾を取得/文字列の末尾を削除(php)

文字列の末尾を取得する

$str = "hello world";
$last01 =  mb_substr($str, -1);


文字列の末尾から2文字を取得
 $last02 = mb_substr($str, -2);

参考:
https://php1st.com/752

文字列の末尾を削除する

$str = "hello world";
$delete_last = rtrim($str, 'd');

参考:
https://blog.codecamp.jp/php-string-remove


PR

コメント

ブログ内検索

カレンダー

03 2025/04 05
S M T W T F S
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30