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,405
  • 13
  • 37
  • 72

1 Answers1

2

Something like this will do?

$str='Social\Notify\Models\User';
echo explode('\\',$str)[3]; //"prints" User
Shankar Narayana Damodaran
  • 66,874
  • 43
  • 94
  • 124