0

I am new in PHP and I have some text saved in a variable. I am trying retrieve a the text followed of the first '/' character. Here is what i tried.

$var="xxxxx/ttt/tttt/tttt.txt";
echo $str . "<br />";
echo trim($str,"/");

The output must be ttt/tttt/tttt.txt. I will highly appreciate if i can get some help. Thank you.

fusion3k
  • 11,568
  • 4
  • 25
  • 47
Gunesh.John
  • 95
  • 2
  • 8

2 Answers2

0

You can try with explode function

$var="xxxxx/ttt/tttt/tttt.txt";

$split = explode('/', $var,2); // it will expload by first occurance of / (delimeter)

//$split[0] will contain "xxxxx"

echo  $split[1]; // output = ttt/tttt/tttt.txt
Narayan
  • 1,670
  • 1
  • 19
  • 37
0

Based on the duplication, here's your answer:

$data = "xxxxx/ttt/tttt/tttt.txt";

$whatIWant = substr($data, strpos($data, "/") + 1);

echo $whatIWant;
LMS94
  • 1,016
  • 1
  • 7
  • 14