1 2 3 4 5 6 7
<?php $haystack="/this/is/the/haystack/string/to/be/trimmed/using/a/needle/string/"; $needle="to/be/"; $result = explode($needle, $haystack); $first_part = $result[0]; echo $first_part; ?>
1
/this/is/the/haystack/string/