-1

String Function in PHP:

$img = "WhatsApp Image 2019-11-18 at 17.15.42.jpeg | xyz.com/content/uploads/wcpa_uploads/image.jpg";

using string functions, how can I get complete text after | symbol, I mean only the complete url of image should be saved in variable.

Ashish Bafna
  • 43
  • 1
  • 10

2 Answers2

0

There are several methods for that. If you do not want to regex or split to array, try this:

$path = trim(substr(strstr($img, "|"), 1));
Anatoliy R
  • 1,749
  • 2
  • 14
  • 20
0

Simplest way:

trim(explode('|', $img)[1])
סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
Gabriel Vasile
  • 2,110
  • 1
  • 14
  • 26