I am formatting data that is stored in two arrays using foreach
loops and an If Statement
. I am happy with my current output; however, I am having one issue. I don't want categories with No data or - TBD -
as a data value to be displayed.
Here is my current PHP:
<?php
foreach ($finaltitle as $titlenumber => $titlename){
foreach ($techData as $tsnumber => $tsname){
if ($tsnumber == $titlenumber){
$finaltsdata = "<b>".$titlename." (".$tsnumber.") "."</b>: ".$tsname."<br>";
echo $finaltsdata;
}
}
}
?>
And its respective output:
Vehicle Name (1) : Audi S4
Body Style (2) : 5 Door Wagon
Drivetrain (6) : All-Wheel Drive
EPA Classification (7) : Small Station Wagon
Passenger Capacity (8) : 5
Passenger Volume (9) : 90.8
Base Curb Weight (10) : 4101
EPA Fuel Economy Est - City (26) : 14
EPA Fuel Economy Est - Hwy (27) : 21
Dead Weight Hitch - Max Trailer Wt. (31) : - TBD -
Dead Weight Hitch - Max Tongue Wt. (32) : - TBD -
Wt Distributing Hitch - Max Trailer Wt. (33) : - TBD -
Wt Distributing Hitch - Max Tongue Wt. (34) : - TBD -
Engine Order Code (40) :
Engine Type (41) : Gas V8
Displacement (42) : 4.2L/254
Fuel System (43) : SEFI
SAE Net Horsepower @ RPM (48) : 340 @ 6800
SAE Net Torque @ RPM (49) : 302 @ 3500
Trans Order Code (51) :
Trans Type (52) : 6
So in the case of this output I wouldn't want the following categories to be displayed because they either don't have a data value or their data value equals - TBD -
.
Dead Weight Hitch - Max Trailer Wt. (31) : - TBD -
Dead Weight Hitch - Max Tongue Wt. (32) : - TBD -
Wt Distributing Hitch - Max Trailer Wt. (33) : - TBD -
Wt Distributing Hitch - Max Tongue Wt. (34) : - TBD -
Engine Order Code (40) :
Trans Order Code (51) :
Thanks so much for your help!
Aucun commentaire:
Enregistrer un commentaire