0

i have this string

$string = "Social\Notify\Models\User";

How can i tell to php how select just the fourth segment of it? in this case just the word User?

Fabrizio Fenoglio
  • 5,767
  • 14
  • 38
  • 75

1 Answers1

2

Something like this will do?

$str='Social\Notify\Models\User';
echo explode('\\',$str)[3]; //"prints" User
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126