1

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.

asked Jun 20, 2016 at 8:39
4
  • is there only one | character in the string? Commented Jun 20, 2016 at 8:41
  • And what you have tried so far? Commented Jun 20, 2016 at 8:41
  • @RomanPerekhrest yes. Commented Jun 20, 2016 at 8:42
  • Possible duplicate of comma-separated string to array Commented Jun 20, 2016 at 9:39

6 Answers 6

2

Use explode

explode("|","[email protected]|d76c3c301eb754c62b981f7208158a9f")[1];

check this : https://eval.in/591968

answered Jun 20, 2016 at 8:42
Sign up to request clarification or add additional context in comments.

Comments

2

Use stristr()

$str="[email protected]|d76c3c301eb754c62b981f7208158a9f";
echo ltrim(stristr($str, '|'),"|"); 
answered Jun 20, 2016 at 8:43

Comments

2

Another short solution using substr and strpos functions:

$str = "[email protected]|d76c3c301eb754c62b981f7208158a9f";
$result = substr($str, strpos($str, "|") + 1); // contains "d76c3c301eb754c62b981f7208158a9f"
answered Jun 20, 2016 at 8:47

Comments

2

Split your string by using explode(). Then return the last element of the array using end()

 end(explode('|', '[email protected]|d76c3c301eb754c62b981f7208158a9f'));
answered Jun 20, 2016 at 8:47

Comments

1

Try below code

substr( strstr('[email protected]|d76c3c301eb754c62b981f7208158a9f', '|'), 1);
answered Jun 20, 2016 at 8:42

Comments

1

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

answered Jun 20, 2016 at 9:20

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.