如何在字符串中找到一个特殊字符,并将该字符之后的所有值存储在变量中


How can I find a special character in my string and store all value after this character in a variable

我试图从字符串中找到特殊字符$@,并试图将这些特殊字符之后的所有值存储在变量中,但我无法完成此任务。如何在整个字符串中找到这个$@特殊字符,并将这个特殊字符之后的所有值存储在变量中。我的字符串是:

 92~SAPL/1200/2012~2~LAXMAN SINGH AND OTHERS~SHANKER SINGH AND OTHERS~D~
 2014-04-10~09:31:13
 07/04/2014|93~SAPL/275/1998~1~RAM SWAROOP AND OTHERS~BABU RAM AND OTHERS~D~
 2014-04-10~09:31:13 07/04/2014|94~FAFOD/52/2013~3~RAM KUMAR PANDEY~RAJENDRA PANDEY AND
 ANOTHER~D~2014-04-10~09:31:13 07/04/2014$@2014-04-10~2014-04-09 

试试这个:

$string = "Your Entire String";
$explodedString = explode('$@', $string);
if(count($explodedString) > 1) {
   unset($explodedString[0]);
   $returnString = count($explodedString) > 1 ? $explodedString : $explodedString[0];
} else {
   $returnString = null;
}
if(is_array($returnString)) {
   //if you want to divide the string only to the first occurrence of $@ leave the below line as is else comment it out
   $returnString = implode('', $returnString);
}
echo $returnString;