Reputation: 1105
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
.
Upvotes: 1
Views: 66
Reputation: 379
$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
Upvotes: 1
Reputation: 134
Split your string by using explode(). Then return the last element of the array using end()
end(explode('|', '[email protected]|d76c3c301eb754c62b981f7208158a9f'));
Upvotes: 2
Reputation: 92894
Another short solution using substr
and strpos
functions:
$str = "[email protected]|d76c3c301eb754c62b981f7208158a9f";
$result = substr($str, strpos($str, "|") + 1); // contains "d76c3c301eb754c62b981f7208158a9f"
Upvotes: 2
Reputation: 22532
Use stristr()
$str="[email protected]|d76c3c301eb754c62b981f7208158a9f";
echo ltrim(stristr($str, '|'),"|");
Upvotes: 2
Reputation: 34924
Use explode
explode("|","[email protected]|d76c3c301eb754c62b981f7208158a9f")[1];
check this : https://eval.in/591968
Upvotes: 2
Reputation: 1022
Try below code
substr( strstr('[email protected]|d76c3c301eb754c62b981f7208158a9f', '|'), 1);
Upvotes: 1