I have this value: [email protected]|d76c3c301eb754c62b981f7208158a9f
Best approach to remove all the string from the beginning of the word until the |. The | is the key here , on where to end. The output should be d76c3c301eb754c62b981f7208158a9f.
6 Answers
Use explode
explode("|","[email protected]|d76c3c301eb754c62b981f7208158a9f")[1];
check this : https://eval.in/591968
Comments
Use stristr()
$str="[email protected]|d76c3c301eb754c62b981f7208158a9f";
echo ltrim(stristr($str, '|'),"|");
Comments
Another short solution using substr and strpos functions:
$str = "[email protected]|d76c3c301eb754c62b981f7208158a9f";
$result = substr($str, strpos($str, "|") + 1); // contains "d76c3c301eb754c62b981f7208158a9f"
Comments
Split your string by using explode(). Then return the last element of the array using end()
end(explode('|', '[email protected]|d76c3c301eb754c62b981f7208158a9f'));
Comments
Comments
Use php explode($delimiter,$yourstring) function
$str="[email protected]|d76c3c301eb754c62b981f7208158a9f";
$exploded_str_array=explode('|', $str);
echo $required_str=$exploded_str_array[1];
//this contains the second part of the string delimited by | php manual for the explode function
|character in the string?