3v4l.org

run code in 300+ PHP versions simultaneously
<?php class AC { function actionClosest_AddPointsToResponse() { $points = array('attributes'=>array('dp_id'=>2,)); $res_pnt = 0; $timestamp = 0; $more_records = false; $matching = array( 'Payments' => 'payment2=extract(%item, %id, "DP_Payment", "dpp_id", "dpp_", array("dpp_id"), true, true, true)', /* 'dp_id_uniq' => 'id', 'dp_update' => 'update', 'dp_type' => 'point|type', 'dp_name' => 'point|name', 'dp_description' => 'point|description', 'dp_currency' => 'point|currency', 'dp_company_id' => 'point|company_id', 'dp_tariff_plan' => 'point|tariff_plan', 'PhoneNumbers' => 'point|phone_nums=get(%item, %id, "DP_Phone", "dp_id", "dp_", array("ph_id", "dp_id"), false, false, true, 0)', 'WorkingHours' => 'point|work_hours=get(%item, %id, "DP_WorkingHour", "dp_id", "dp_", array("dp_id"))', 'dp_slot_duration' => 'point|slot_duration', 'dp_slot_number' => 'point|slot_number', 'dp_latitude' => 'geo|latitude', 'dp_longitude' => 'geo|longitude', 'dp_country' => 'geo|country_id', 'dp_region' => 'geo|region', 'dp_city' => 'geo|city', 'dp_post_code' => 'geo|post_code', 'dp_street' => 'geo|street', 'dp_house_number' => 'geo|house_number', 'ServiceList' => 'service|main_service=get(%item, %id, "DP_ServicePrice", "dp_id", "sv_", array("dp_id", "sv_price", "price_schema=>price"))', 'dp_additional_service' => 'service|additional_service', 'Payments' => 'payment=extract(%item, %id, "DP_Payment", "dpp_id", "dpp_", array("dpp_id"), true, true, true)', 'PrepaidCards' => 'payment|prepaid_cards=get(%item, %id, "DP_PrepaidCard", "dp_id", "dp_", array("ppc_id", "dp_id"), false, true, false)', 'Parking' => 'parking=get(%item, %id, "DP_Parking", "parking_id", "parking_", array("parking_id"), true, true)', 'CarWash' => 'car_wash=get(%item, %id, "DP_CarWash", "cw_id", "cw_", array("cw_id", "cw_subcompact_cars", "cw_compact_cars", "cw_suv_minivans", "cw_trucks", "cw_cleaning_method"), true, true)', 'TyreFitting' => 'tyre_fitting=get(%item, %id, "DP_TyreFitting", "tf_id", "tf_", array("tf_id", "tf_install_wheel", "tf_mount_tyres", "tf_wheel_balancing", "tf_tyre_fitting_wheel", "tf_tyre_fitting_car", "tf_disc_repair", "tf_tyre_repair", "tf_inflation", "tf_run_flat_repair", "tf_tyres_recycling", "tf_tyres_storage"), true, true)', 'ParkingCapacity' => 'payment=get(%item, %id, "DP_ParkingCapacity", "parking_id", "pc_", array("parking_id"), true, true)', #'' => '', '' => '', '' => '', #'CarService' => '', */ ); $var = ''; $item = array(); $drevolpoint_id = 2; //$point->dp_id; foreach( $matching as $param => $match ) { if (!preg_match('/^(\w+)(?:\|(\w+))?(?:=(get|extract)\((.*?)\))?$/', $match, $var)) throw new Exception("Unknown DB field mappint: $match (for $param)"); if (!in_array($param, array_keys($point->attributes)) and (!isset($var[4]) or !$var[4])) throw new Exception("Unknown DB field requested: $param (matching for $match)"); $item_name = '$item[\''.$var[1].'\']'; if (isset($var[2]) and $var[2]) $item_name .= '[\''.$var[2].'\']'; print("<hr>Item name = '$item_name'<br>\n"); } } } $aco = new AC; $aco->actionClosest_AddPointsToResponse();

preferences:
56.97 ms | 402 KiB | 5 Q