I am working on a website in which I want to hide text (Hello World, Point A, and Point B) when serialized string is empty. Below is my code:
<p class="font-weight-bold">Hello World</p>
<p class="font-weight-bold">Point A</p>
<?php
$serialized = '';
for ($i = 0; $i < count($data['item']->process_out); $i++) {
if(strcmp($data['item']->process_out[$i]->processs_type, "pickup") == 0)
{
$serialized .= strtolower($data['item']->process_out[$i]->processs_times);
}
}
if($serialized != '')
{
$unserialized = unserialize( $serialized );
foreach($unserialized as $key=>$value)
{
echo $key." ".$value['start']." ".$value['end']."<br/>";
}
}
?>
<p class="mt-2 font-weight-bold text-center">Point B</p>
<?php
$serialized = '';
for ($i = 0; $i < count($data['item']->process_out); $i++) {
if(strcmp($data['item']->process_out[$i]->processs_type, "location_pickup") == 0)
{
$serialized .= strtolower($data['item']->process_out[$i]->processs_times);
}
}
if($serialized != '')
{
$unserialized = unserialize( $serialized );
foreach($unserialized as $key=>$value)
{
echo $key." ".$value['start']." ".$value['end']."<br/>";
}
}
?>
Problem Statement:
Inside Hello World, I have two sections - Point A and Point B.
If both
Point AandPoint Bare empty (meaningserializedstring is empty) and there is no data to show then I don't want to show<p>text forHello World,Point AandPoint Bat all.But if either of them is present (meaning
serializedstring is not empty) then I want to show<p>text forHello Worldand<p>text for whatever it is present (it can bePoint AorPoint B).
Is this possible to do? When the serialize string is empty it is displaying like this:
I don't want those texts to print when the serialized string is empty for Point A or Point B.
