UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

20 lines (16 loc) 632 B
function array_values(input) { // From: http://phpjs.org/functions // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: Brett Zamir (http://brett-zamir.me) // * example 1: array_values( {firstname: 'Kevin', surname: 'van Zonneveld'} ); // * returns 1: {0: 'Kevin', 1: 'van Zonneveld'} var tmp_arr = [], key = ''; if (input && typeof input === 'object' && input.change_key_case) { // Duck-type check for our own array()-created PHPJS_Array return input.values(); } for (key in input) { tmp_arr[tmp_arr.length] = input[key]; } return tmp_arr; }