- print_r: documentation ( source)
- preg_match_all: documentation ( source)
- preg_quote: documentation ( source)
- sprintf: documentation ( source)
<?php
function getStringsBetween($string, $start, $end)
{
$pattern = sprintf('/%s(.*?)%s/',preg_quote($start), '(?:' . preg_quote($end) . '|$)');
preg_match_all($pattern, $string, $matches);
return $matches[1];
}
$y = "@!$+$+$+#+ hsjsjenshsjsjsj#hshsjsj ndjdjjdjdn #sem";
$output = getStringsBetween($y, "#", " ");
print_r($output);