Wondering how I can search through the following array for [law] and just return [fine] for that law?
Array ( [0] => Array (
[law] => Unroadworthy Vehicle
[fine] => 500
[jail] => 0
[statute] => Any registered vehicle that is lacking headlights, taillights, windshields, has extensive damage, or deemed unsafe to operate, can be considered unroadworthy. Vehicles to do not return a registration shall also be considered unroadworthy. )
[1] => Array (
[law] => Headlights Required
[fine] => 500
[jail] => 0
[statute] => Failure to use headlights after dark or in poorly lit areas or roadways )
..(array continues through 108 unique items)
I have this to loop through and display the law in a dropdown
echo "<select name=\"charge\">";
$strJsonFileContents = file_get_contents("./includes/laws.json");
$issue = json_decode($strJsonFileContents, true);
$arrlength = count($issue);
for ($x = 0; $x < $arrlength; $x++)
{
$law = $issue[$x][law];
echo "<option name=\"law\" value=\"$law\">$law</option>";
}
echo "</select><br><br>";
I'm actually not going to do the hidden element part.
I want to search through json_decode for [law] and return it's [fine]