I have a string
$var1 = colors<select><option value = 'blue'></option></select>
I can get the value colors as a string with this statement
$needle1 = "<select>";
$result_string1 = substr("$var1",0,strpos($var1,$needle1));
echo "$result_string1";
will give me
colors.
Then I want to get everything between <select> and </select>
so I use the following code
$needle3 = "</select><br>";
$result_string1a = substr("$var1", strlen($result_string1), strpos($var1, $needle3));
There is a minor problem here.
when I say
echo "$result_string1a";
The expected result is
<select><option value = 'blue'></option></select>
But I get the following
<select><option value = 'blue'></option></select
The </select appears. Since it is not closed with a greater than sign, I have problems with further processing.