Multiple functions?

I’m trying to use 2 (mayby more) allmost identical functions on the same page but am having trouble getting the data out of each. Example below:

function get_string_between($string, $start, $end){
	$string = " ".$string;
	$ini = strpos($string,$start);
	if ($ini == 0) return "";
	$ini += strlen($start);
	$len = strpos($string,$end,$ini) - $ini;
	return substr($string,$ini,$len);

function GetData1() {
	$html = '<div>Now this is something!</div><div id="submission">This should be in the output1...</div>';
	$parsed = get_string_between($html, "<div id=\\"submission\\">", "</div>");
	$returndata[0] = $parsed;
	return $returndata;

function GetData2() {
	$html = '<div>This is a test</div><div id="content">This should be in the output2...</div><p>Hey hey... </p>';
	$parsed = get_string_between($html, "<div id=\\"content\\">", "</div>");
	$returndata[0] = $parsed;
	return $returndata;

$output1 = GetData1();
echo 'Output1: '.$output1[0].'<br>';

$output1 = GetData2();
echo 'Output2: '.$output2[0].'<br>';

What do I do wrong and is it possible?

Thanks in advance :wink:

substr returns a single string, so $returndata[0] = $parsed is wrong.

It should just be

return $parsed;


return get_string_between(…