Here i have the variable $json concatenated with possible three conditions.
According the below conditions $first , $second and $third, the output should get concatenate with pipe. So that the output should be either three given below
Expected
first
or
first | second
or
first | second | third
Here is my Code simplified :
<?php
$json = "";
$first = "1";
$second = "1";
$third = "1";
$pipe = "|";
if ($first == 1)
{
$json .= "first";
}
$json .= $pipe;
if ($second == 1)
{
$json .= "second";
}
$json .= $pipe;
if ($third == 1)
{
$json .= "third";
}
echo $json;
?>
How can i make the $pipe variable to get my output expected for the variable $json
Note : As i use some complex flexi grid , implode still makes little complex