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.

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

Sign up to request clarification or add additional context in comments.

Comments

2

Use stristr()

$str="[email protected]|d76c3c301eb754c62b981f7208158a9f";
echo ltrim(stristr($str, '|'),"|"); 

Comments

2

Another short solution using substr and strpos functions:

$str = "[email protected]|d76c3c301eb754c62b981f7208158a9f";
$result = substr($str, strpos($str, "|") + 1); // contains "d76c3c301eb754c62b981f7208158a9f"

Comments

2

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

 end(explode('|', '[email protected]|d76c3c301eb754c62b981f7208158a9f'));

Comments

1

Try below code

substr( strstr('[email protected]|d76c3c301eb754c62b981f7208158a9f', '|'), 1);

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.