@ 2018-03-12T00:55:28Z <?php
function searchByVINs ($VINs,$fields) {
/*
// test multi-VIN batching via textarea at bottom of https://vpic.nhtsa.dot.gov/api/
$stream_options_content = http_build_query(["data" => implode(";", $VINS), "format" => "JSON"]);
$stream_options = [
'http' => [
'header' => "Content-Type: application/x-www-form-urlencoded\r\n".
"Content-Length: ".strlen($postdata)."\r\n",
'method' => "POST",
'content' => $postdata
]
];
$context = stream_context_create($stream_options);
$apiURL = "https://vpic.nhtsa.dot.gov/api/vehicles/DecodeVINValuesBatch/";
if (!$fp = @fopen($apiURL, "rb", FALSE, $context)) {
return ["success" => false, "response" => "Unable to open stream"];
}
if (!$response = stream_get_contents($fp),true)) {
return ["success" => false, "response" => "Unable to receive streamed data"];
}
*/
$response = '{"Count":2,"Message":"Results returned successfully","SearchCriteria":"","Results":[{"ABS":"","AEB":"","AdaptiveCruiseControl":"","AdaptiveHeadlights":"","AdditionalErrorText":"","AirBagLocCurtain":"","AirBagLocFront":"","AirBagLocKnee":"","AirBagLocSeatCushion":"","AirBagLocSide":"","Artemis":"","AxleConfiguration":"","Axles":"","BasePrice":"","BatteryA":"","BatteryA_to":"","BatteryCells":"","BatteryInfo":"","BatteryKWh":"","BatteryKWh_to":"","BatteryModules":"","BatteryPacks":"","BatteryType":"","BatteryV":"","BatteryV_to":"","BedLengthIN":"","BedType":"","BlindSpotMon":"","BodyCabType":"","BodyClass":"Wagon","BrakeSystemDesc":"","BrakeSystemType":"Hydraulic","BusFloorConfigType":"","BusLength":"","BusType":"","CAFEBodyType":"","CAFEMake":"","CAFEModel":"","CashForClunkers":"","ChargerLevel":"","ChargerPowerKW":"","CoolingType":"","Country":"","CurbWeightLB":"","CustomMotorcycleType":"","DestinationMarket":"","DisplacementCC":"2200.0","DisplacementCI":"134.25223700841","DisplacementL":"2.2","Doors":"4","DriveType":"","DriverAssist":"","ESC":"","EVDriveUnit":"","ElectrificationLevel":"","EngineConfiguration":"","EngineCycles":"","EngineCylinders":"4","EngineHP":"","EngineHP_to":"","EngineKW":"","EngineManufacturer":"GM","EngineModel":"L61\/LBZ","EntertainmentSystem":"","EquipmentType":"","ErrorCode":"1 - VIN decoded clean. Check Digit (9th position) does not calculate properly.","ForwardCollisionWarning":"","FuelInjectionType":"Multipoint Fuel Injection (MPFI)","FuelTypePrimary":"Gasoline","FuelTypeSecondary":"","GVWR":"Class 1D: 5,001 - 6,000 lb (2,268 - 2,722 kg)","LaneDepartureWarning":"","LaneKeepSystem":"","Make":"CHEVROLET","Manufacturer":"GENERAL MOTORS LLC","ManufacturerId":"984","ManufacturerType":"","Model":"HHR","ModelYear":"2006","MotorcycleChassisType":"","MotorcycleSuspensionType":"","NCAPBodyType":"","NCAPMake":"","NCAPModel":"","NCICCode":"","NCSABodyType":"","NCSAMake":"","NCSAModel":"","Note":"","OtherBusInfo":"","OtherEngineInfo":"L61: 2.2L, 4Cyl, Aluminium, DOHC MFI\u000d\u000aLBZ: 6.6L, V8, DI, Turbo Diesel, inc HP","OtherMotorcycleInfo":"","OtherRestraintSystemInfo":"","OtherTrailerInfo":"","ParkAssist":"","PlantCity":"Ramos Arizpe","PlantCompanyName":"GMNA","PlantCountry":"Mexico","PlantState":"","PossibleValues":"","Pretensioner":"","RearVisibilityCamera":"","SeatBeltsAll":"","SeatRows":"","Seats":"","Series":"LS","Series2":"","SteeringLocation":"","SuggestedVIN":"","TPMS":"","TopSpeedMPH":"","TrackWidth":"","TractionControl":"","TrailerBodyType":"","TrailerLength":"","TrailerType":"","TransmissionSpeeds":"","TransmissionStyle":"","Trim":"1\/2 Ton","Trim2":"","Turbo":"","VIN":"3GNDA13D76S000000","ValveTrainDesign":"Dual Overhead Cam (DOHC)","VehicleType":"MULTIPURPOSE PASSENGER VEHICLE (MPV)","WheelBaseLong":"","WheelBaseShort":"","WheelBaseType":"","WheelSizeFront":"","WheelSizeRear":"","Wheels":"","Windows":""},{"ABS":"","AEB":"","AdaptiveCruiseControl":"","AdaptiveHeadlights":"","AdditionalErrorText":"","AirBagLocCurtain":"1st & 2nd Rows","AirBagLocFront":"1st Row (Driver & Passenger)","AirBagLocKnee":"","AirBagLocSeatCushion":"","AirBagLocSide":"1st Row (Driver & Passenger)","Artemis":"","AxleConfiguration":"","Axles":"","BasePrice":"","BatteryA":"","BatteryA_to":"","BatteryCells":"","BatteryInfo":"","BatteryKWh":"","BatteryKWh_to":"","BatteryModules":"","BatteryPacks":"","BatteryType":"","BatteryV":"","BatteryV_to":"","BedLengthIN":"","BedType":"","BlindSpotMon":"","BodyCabType":"","BodyClass":"Wagon","BrakeSystemDesc":"","BrakeSystemType":"","BusFloorConfigType":"","BusLength":"","BusType":"","CAFEBodyType":"","CAFEMake":"","CAFEModel":"","CashForClunkers":"","ChargerLevel":"","ChargerPowerKW":"","CoolingType":"","Country":"","CurbWeightLB":"","CustomMotorcycleType":"","DestinationMarket":"","DisplacementCC":"2400.0","DisplacementCI":"146.45698582735","DisplacementL":"2.4","Doors":"","DriveType":"4x2","DriverAssist":"","ESC":"","EVDriveUnit":"","ElectrificationLevel":"","EngineConfiguration":"","EngineCycles":"","EngineCylinders":"","EngineHP":"","EngineHP_to":"","EngineKW":"","EngineManufacturer":"","EngineModel":"DOHC MPI THETA-II","EntertainmentSystem":"","EquipmentType":"","ErrorCode":"1 - VIN decoded clean. Check Digit (9th position) does not calculate properly.","ForwardCollisionWarning":"","FuelInjectionType":"Multipoint Fuel Injection (MPFI)","FuelTypePrimary":"Gasoline","FuelTypeSecondary":"","GVWR":"Class 1C: 4,001 - 5,000 lb (1,814 - 2,268 kg)","LaneDepartureWarning":"","LaneKeepSystem":"","Make":"KIA","Manufacturer":"HYUNDAI-KIA AMERICA TECHNICAL CENTER INC (HATCI)","ManufacturerId":"1034","ManufacturerType":"","Model":"Sorento","ModelYear":"2012","MotorcycleChassisType":"","MotorcycleSuspensionType":"","NCAPBodyType":"","NCAPMake":"","NCAPModel":"","NCICCode":"","NCSABodyType":"","NCSAMake":"","NCSAModel":"","Note":"","OtherBusInfo":"","OtherEngineInfo":"","OtherMotorcycleInfo":"","OtherRestraintSystemInfo":"","OtherTrailerInfo":"","ParkAssist":"","PlantCity":"","PlantCompanyName":"Kia Motor Manufacturing, Georgia","PlantCountry":"United States (USA)","PlantState":"Georgia","PossibleValues":"","Pretensioner":"","RearVisibilityCamera":"","SeatBeltsAll":"Manual","SeatRows":"","Seats":"","Series":"GL(Middle-low grade)","Series2":"","SteeringLocation":"","SuggestedVIN":"","TPMS":"Direct","TopSpeedMPH":"","TrackWidth":"","TractionControl":"","TrailerBodyType":"","TrailerLength":"","TrailerType":"","TransmissionSpeeds":"","TransmissionStyle":"","Trim":"","Trim2":"","Turbo":"","VIN":"5XYKT3A12CG000000","ValveTrainDesign":"Dual Overhead Cam (DOHC)","VehicleType":"MULTIPURPOSE PASSENGER VEHICLE (MPV)","WheelBaseLong":"","WheelBaseShort":"","WheelBaseType":"","WheelSizeFront":"","WheelSizeRear":"","Wheels":"","Windows":""}]}';
if(($data = @json_decode($response,true)) === null && json_last_error()!==JSON_ERROR_NONE){
return ["success" => false, "response" => "Unable to parse streamed data"];
}
if (!isset($data["Message"]) || $data["Message"] != "Results returned successfully") {
return ["success" => false, "response" => "Received unsuccessful dataset"];
}
$return = [];
$keys = array_flip($fields);
foreach ($data["Results"] as $dataset) {
$isolated = array_intersect_key($dataset,$keys); // only retain the elements with keys that match $fields values
$sorted = array_replace($keys,$isolated); // order the dataset by order of elements in $fields
$return[] = $sorted;
}
return ["success" => true, "response" => $return];
}
$VINs = ["3GNDA13D76S000000", "5XYKT3A12CG000000"];
$fields = ["VIN", "ModelYear", "Make", "FuelTypePrimary", "DriveType", "BodyClass"];
$response = searchByVINs($VINs,$fields);
if (!$response["success"]) {
echo "Oops, the api call failed. {$response["response"]}";
} else {
foreach ($response["response"] as $item){
echo "<div>\n";
foreach ($item as $key => $value) {
echo "\t<div>$key: $value</div>\n";
}
echo "</div>\n";
}
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.4.12 0.013 0.007 20.50 8.4.11 0.015 0.007 22.38 8.4.10 0.009 0.013 18.63 8.4.9 0.013 0.007 18.76 8.4.8 0.010 0.010 18.87 8.4.7 0.009 0.003 18.86 8.4.6 0.005 0.004 20.48 8.4.5 0.006 0.003 18.74 8.4.4 0.015 0.004 17.83 8.4.3 0.010 0.010 19.64 8.4.2 0.004 0.018 19.43 8.4.1 0.007 0.004 17.54 8.3.25 0.013 0.006 18.88 8.3.24 0.009 0.010 21.12 8.3.23 0.014 0.004 16.77 8.3.22 0.010 0.009 20.89 8.3.21 0.010 0.006 16.76 8.3.20 0.005 0.003 16.55 8.3.19 0.008 0.003 16.89 8.3.18 0.014 0.006 18.93 8.3.17 0.010 0.010 16.85 8.3.16 0.008 0.000 17.43 8.3.15 0.013 0.003 18.95 8.3.14 0.006 0.003 19.13 8.3.13 0.003 0.006 18.46 8.3.12 0.003 0.006 20.77 8.3.11 0.004 0.007 20.94 8.3.10 0.008 0.000 24.06 8.3.9 0.007 0.007 26.77 8.3.8 0.003 0.006 18.55 8.3.7 0.014 0.003 16.75 8.3.6 0.007 0.011 18.46 8.3.5 0.007 0.010 18.34 8.3.4 0.010 0.010 18.88 8.3.3 0.012 0.003 18.84 8.3.2 0.008 0.000 21.85 8.3.1 0.000 0.008 23.71 8.3.0 0.008 0.000 23.66 8.2.29 0.012 0.007 20.42 8.2.28 0.013 0.007 18.42 8.2.27 0.007 0.011 18.71 8.2.26 0.004 0.011 16.69 8.2.25 0.013 0.009 16.62 8.2.24 0.006 0.003 19.20 8.2.23 0.004 0.012 22.58 8.2.22 0.007 0.003 37.54 8.2.21 0.009 0.006 26.77 8.2.20 0.003 0.010 16.50 8.2.19 0.004 0.012 16.58 8.2.18 0.008 0.008 16.63 8.2.17 0.011 0.004 22.96 8.2.16 0.014 0.000 20.44 8.2.15 0.004 0.004 24.18 8.2.14 0.009 0.000 24.66 8.2.13 0.003 0.006 20.89 8.2.12 0.005 0.002 26.35 8.2.11 0.007 0.003 21.04 8.2.10 0.009 0.003 18.03 8.2.9 0.005 0.003 18.03 8.2.8 0.000 0.008 18.09 8.2.7 0.004 0.004 17.63 8.2.6 0.006 0.003 17.63 8.2.5 0.004 0.004 17.50 8.2.4 0.005 0.005 18.05 8.2.3 0.004 0.004 18.08 8.2.2 0.007 0.000 18.22 8.2.1 0.000 0.008 18.04 8.2.0 0.000 0.008 18.04 8.1.33 0.011 0.009 22.23 8.1.32 0.010 0.010 16.08 8.1.31 0.007 0.007 16.69 8.1.30 0.004 0.012 18.38 8.1.29 0.009 0.000 18.88 8.1.28 0.009 0.006 25.92 8.1.27 0.005 0.003 23.91 8.1.26 0.005 0.003 26.35 8.1.25 0.004 0.004 28.09 8.1.24 0.006 0.003 23.97 8.1.23 0.009 0.003 20.97 8.1.22 0.003 0.005 17.79 8.1.21 0.000 0.008 18.77 8.1.20 0.005 0.005 17.35 8.1.19 0.004 0.007 17.23 8.1.18 0.004 0.004 18.10 8.1.17 0.000 0.009 17.62 8.1.16 0.005 0.003 18.85 8.1.15 0.000 0.008 20.21 8.1.14 0.011 0.000 17.75 8.1.13 0.003 0.007 17.57 8.1.12 0.004 0.004 17.56 8.1.11 0.003 0.005 17.52 8.1.10 0.004 0.004 17.41 8.1.9 0.004 0.004 17.50 8.1.8 0.000 0.008 17.40 8.1.7 0.000 0.007 17.50 8.1.6 0.004 0.008 17.58 8.1.5 0.003 0.007 17.55 8.1.4 0.000 0.008 17.56 8.1.3 0.003 0.006 17.66 8.1.2 0.004 0.004 17.61 8.1.1 0.000 0.008 17.67 8.1.0 0.004 0.004 17.55 8.0.30 0.005 0.002 20.02 8.0.29 0.000 0.008 16.88 8.0.28 0.007 0.000 18.43 8.0.27 0.000 0.007 17.30 8.0.26 0.007 0.000 16.86 8.0.25 0.003 0.003 17.02 8.0.24 0.007 0.004 16.96 8.0.23 0.006 0.003 16.95 8.0.22 0.000 0.007 16.91 8.0.21 0.000 0.007 16.95 8.0.20 0.004 0.004 16.97 8.0.19 0.000 0.010 16.96 8.0.18 0.003 0.006 16.97 8.0.17 0.006 0.003 16.93 8.0.16 0.004 0.004 16.99 8.0.15 0.007 0.000 16.88 8.0.14 0.000 0.007 16.87 8.0.13 0.000 0.006 13.40 8.0.12 0.004 0.004 16.90 8.0.11 0.004 0.004 16.95 8.0.10 0.007 0.000 16.78 8.0.9 0.005 0.002 16.82 8.0.8 0.012 0.004 16.85 8.0.7 0.000 0.008 16.82 8.0.6 0.004 0.004 16.88 8.0.5 0.000 0.007 16.78 8.0.3 0.010 0.008 16.99 8.0.2 0.008 0.011 17.40 8.0.1 0.000 0.007 16.91 8.0.0 0.016 0.003 16.93 7.4.33 0.003 0.003 15.55 7.4.32 0.000 0.006 16.50 7.4.30 0.000 0.007 16.65 7.4.29 0.003 0.003 16.64 7.4.28 0.006 0.003 16.63 7.4.27 0.000 0.007 16.46 7.4.26 0.006 0.003 16.63 7.4.25 0.004 0.004 16.48 7.4.24 0.005 0.003 16.54 7.4.23 0.000 0.008 16.53 7.4.22 0.004 0.004 16.64 7.4.21 0.003 0.011 16.61 7.4.20 0.008 0.000 16.74 7.4.16 0.006 0.010 16.54 7.4.14 0.008 0.010 17.86 7.4.13 0.009 0.009 16.59 7.4.12 0.008 0.009 16.57 7.4.11 0.004 0.013 16.58 7.4.10 0.009 0.009 16.38 7.4.9 0.012 0.006 16.46 7.4.8 0.007 0.013 19.39 7.4.7 0.004 0.019 16.29 7.4.6 0.011 0.006 16.52 7.4.5 0.000 0.016 16.73 7.4.4 0.019 0.004 16.59 7.4.0 0.006 0.007 14.93 7.3.33 0.005 0.000 13.36 7.3.32 0.003 0.003 13.21 7.3.31 0.003 0.005 16.26 7.3.30 0.003 0.003 16.48 7.3.29 0.004 0.004 16.28 7.3.28 0.005 0.013 16.45 7.3.26 0.014 0.007 16.51 7.3.25 0.012 0.008 16.48 7.3.24 0.008 0.010 16.39 7.3.23 0.010 0.007 16.29 7.3.21 0.014 0.007 16.68 7.3.20 0.009 0.009 16.45 7.3.19 0.014 0.003 16.53 7.3.18 0.006 0.011 16.50 7.3.17 0.010 0.007 16.50 7.3.16 0.008 0.012 16.50 7.2.33 0.015 0.006 16.74 7.2.32 0.006 0.013 16.88 7.2.31 0.017 0.000 16.91 7.2.30 0.016 0.006 16.82 7.2.29 0.014 0.004 16.56 7.2.6 0.013 0.000 16.97 7.2.3 0.020 0.012 17.91 7.2.2 0.019 0.011 18.14 7.2.1 0.016 0.016 18.05 7.2.0 0.012 0.017 17.79 7.1.20 0.003 0.010 15.86 7.1.15 0.019 0.011 16.93 7.1.14 0.020 0.009 16.52 7.1.13 0.016 0.015 16.96 7.1.12 0.016 0.012 16.81 7.1.11 0.015 0.008 15.86 7.1.10 0.012 0.011 16.45 7.1.9 0.013 0.012 16.16 7.1.8 0.014 0.008 16.43 7.1.7 0.012 0.006 15.61 7.1.6 0.026 0.018 33.40 7.1.5 0.036 0.013 32.86 7.1.4 0.026 0.012 32.58 7.1.3 0.036 0.011 32.84 7.1.2 0.029 0.011 32.96 7.1.1 0.011 0.011 14.60 7.1.0 0.011 0.011 14.97
preferences:dark mode live preview ace vim emacs key bindings
34.4 ms | 403 KiB | 5 Q