どうも、ちょげ(@chogetarou)です。
文字列(string)の指定文字以降を切り出す方法を紹介します。
方法

文字列(string)の指定文字以降を切り出す方法は、2つあります。
explode()
ひとつは、explode()を使う方法です。
まず、explode()を呼び出します。
explode()の第1引数に指定文字、第2引数に対象の文字列、第3引数に「2」を指定します。
そして、explode()の戻り値のインデックス「1」にアクセスします。
//char=指定文字, text=対象の文字列,
$result = explode(char, text, 2)[1];
上記のexplode()の戻り値のインデックス「1」にアクセスすることで、対象の文字列(string)の指定文字以降を切り出せます。
使用例
<?php
$text = "Hello,World";
$result = explode(",", $text, 2)[1];
echo $result;
?>
出力:
World
substr() + strpos()
もうひとつは、substr()とstrpos()を使う方法です。
まず、substr()を呼び出します。
substr()の第1引数に対象の文字列、第2引数に「strpos() + 1」を指定します。
strpos()の第1引数に対象の文字列、第2引数に特定の文字を指定します。
//char=指定文字, text=対象の文字列,
$result = substr(text, strpos(text, char) + 1);
上記のsubstr()は、対象の文字列(string)の指定文字以降を切り出します。

PHP: substr - Manual
PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites i...

PHP: strpos - Manual
PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites i...
使用例
<?php
$text = "Hello,World";
$result = substr($text, strpos($text, ",") + 1);
echo $result;
?>
出力:
World
まとめ
文字列(string)の指定文字以降を切り出す方法は、次の2つです。
- explode()を使う方法
$result = explode(char, text, 2)[1]; - substr()とstrpos()を使う方法
$result = substr(text, strpos(text, char) + 1);
コメント