I have a database where I am storing a long string in one column. I am using two different delimiters. I am using $$ to separate the 4 inputs user can input. I am using ** to separate between each time the user enters the inputs (keep up with historical). I am pulling the data and trying to display it within my php file. Here is a portion of my code. My code is working when no ** delimiter is found (only $$ is found). However, when I enter the if statement due to finding **, my code quits printing data out. I get no errors just a blank section on my page. Do I have something set wrong in the while ($lUB < $bSize){} portion?
if ($userData[$index] != "")
{
if (strpos($userData[$index], '**') != false)
{
echo "here 0";
$userDataB = explode("**", $userData[$index]);
$lUB = 0;
$bSize = count($userDataB);
while ($lUB < $bSize)
{
$dataparse = explode("$$", $userDataB[$lUB]);
echo ("<tr>");
echo("<td>");
echo $dataparse[1];
echo("</td>");
echo("<td>");
echo $dataparse[2];
echo("</td>");
echo("<td>");
echo $dataparse[0];
echo("</td>");
echo("</tr>");
unset($dataparse);
$lUB = $lUB+1;
}
}
else
{
echo "here 1";
$dataparse = explode("$$", $userData[$index]);
echo ("<tr>");
echo("<td>");
echo $dataparse[1];
echo("</td>");
echo("<td>");
echo $dataparse[2];
echo("</td>");
echo("<td>");
echo $dataparse[0];
echo("</td>");
echo("</tr>");
}
}
else
{
echo "here 2";
}
If string is at the start of another string, strpos will return 0, which is equal to false in an if block, either you should use === operator or try to use some other function.