3v4l.org

run code in 300+ PHP versions simultaneously
<?php $results = array ( 0 => array ( 'id' => 1, 'location' => 3, 'location_fees' => 3, 'gross_percentage' => 25, 'transaction_percentage' => 0, 'user_name' => 'admin', 'user_id' => 1, 'gross' => 'yes', 'transaction' => 'no' ), 1 => array ( 'id' => 2, 'location' => 5, 'location_fees' => 5, 'gross_percentage' => 0, 'transaction_percentage' => 24, 'user_name' => 'admin', 'user_id' => 1, 'gross' => 'no', 'transaction' => 'yes' ), 2 => array ( 'id' => 3, 'location' => 2, 'location_fees' => 5, 'gross_percentage' => 10, 'transaction_percentage' => 0, 'user_name' => 'admin', 'user_id' => 1, 'gross' => 'yes', 'transaction' => 'no' ) ); $search = ['gross' => 'yes']; foreach ($results as $k => $v) { echo "key $k<br>" . PHP_EOL; if ($v['gross'] == $search['gross'] ) { $location_fees = $v['location_fees']; echo "The location fees: ". $location_fees ." % <br><br>" . PHP_EOL; $gross_percentage = $v['gross_percentage']; echo "The gross_percentage is: ".$gross_percentage ."% <br><br>" . PHP_EOL; } else { $tran_perc = $v['transaction_percentage']; echo "The locations percentage is: ".$tran_perc ." % <br>" . PHP_EOL; $the_loc = $v['location']; echo "The location is: ".$the_loc ." <br>" . PHP_EOL; $location_fees = $v['location_fees']; echo "The location fees: ". $location_fees ." % <br><br>" . PHP_EOL; } }

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
156.93 ms | 3400 KiB | 10 Q