I have a variable with delimiters. I have three countries CountryA, CountryB & CountryC.
The first delimiter is the # which specifies the start and end of the Country name.
The second delimiter is the | pipe. So under each country, we there is a set of data separated individually by the pipe.
The third delimiter is the % which specifies the end of each set of data above.
$sample="CountryA#Test1|101|Test2|%Test0|220|Test3|%#CountryB#Test4|103|Test5|%
Test6|400|Test7|%Test8|500|Test9|%#CountryC#TestA|230|TestB|%";
The above variable organized looks like this:
CountryA#
Test1|101|Test2|%
Test0|220|Test3|%
#CountryB#
Test4|103|Test5|%
Test6|400|Test7|%
Test8|500|Test9|%
#CountryC#
TestA|230|TestB|%
The delimiters #,| and % help identify where each data starts and ends. In the country, the first element does not have a starting # because it's not important. The subsequent countries have a starting and closing # to help identify where the country name is.
Objective:

I tried using explode # to first get the country names before wrapping them inside html tags but nothing happens.
$pieces = explode("#", $sample);
foreach($pieces as $value){
return $value . '<br>';
}
