<?php
define('VALIDTYPES', [
'double' => 'd',
'integer' => 'i',
'resource' => 'b', // I haven't actually researched/tested this
'string' => 's',
]);
$params = [1, -3.5, 'stringy', (object)[]];
$params = [1, -3.5, 'stringy'];
$types = array_reduce(
$params,
function($carry, $item) {
$type = gettype($item);
if (!isset(VALIDTYPES[$type])) {
throw new Exception('unexpected data type');
} else {
return $carry . VALIDTYPES[$type];
}
},
'');
var_export($types);
preferences:
51.31 ms | 402 KiB | 5 Q