Created
September 28, 2015 19:37
-
-
Save aradnom/734a06445b19f7d554b1 to your computer and use it in GitHub Desktop.
Explode array component string into usable array of properties, i.e. 'field[subfield1][subfield2][subfield3]' => ["field", "subfield1", "subfield2", "subfield3"]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Explode array component string into usable array of properties, i.e. | |
* 'field[subfield1][subfield2][subfield3]' => | |
* ["field", "subfield1", "subfield2", "subfield3"] | |
* | |
* @param {String} string String of fields | |
* | |
* @return {Array} Returns array of field properties | |
*/ | |
function arrayStringToProperties ( string ) { | |
return string | |
.split( ']' ) | |
.join( '' ) | |
.split( '[' ) | |
.filter( function ( v ) { | |
return v; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment