How to get all letters without the last part of string, for example:
$string = 'namespace\name\driver\some\model';
The expected output is:
namespace\name\driver\some\
Find postion of slash frm the right - you have to escape it with additional \
<?php
$string = "namespace\name\driver\some\model";
$lastslash = strrpos($string,"\\") + 1;
$new_string = substr($string,0,$lastslash);
echo "new string - ".$new_string." ".$lastslash;
?>
If you need to you take a substring, no need to mess with explodes/implodes/array...
Try this basic thing: