Is it possible to use javascript like destructuring to create an associative array from variables with variable names as keys in PHP… in javascript I can do Currently I am stick to repetitive way Can anyone help, it will save me a whole lot of typing? Answer There’s no need to create your own function for this, one already exists: