- array_slice: documentation ( source)
- implode: documentation ( source)
- explode: documentation ( source)
- array_keys: documentation ( source)
- array_pop: documentation ( source)
<?php
$str = "# 12 # # # # Hello World";
$strArr = explode(' ', $str);
$strArrKeys = array_keys($strArr, '#');
$strArrSplit = array_pop($strArrKeys) + 1;
//all after the last #
$subArr = array_slice($strArr, $strArrSplit);
echo implode(' ', $subArr);
//all before the last # (inluding the #).
$subArr = array_slice($strArr, 0, $strArrSplit);
echo implode(' ', $subArr);