Skip to content

Instantly share code, notes, and snippets.

@cmd05
Last active March 23, 2022 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmd05/673e951dc1be1a2b1f395a4ee041b5b5 to your computer and use it in GitHub Desktop.
Save cmd05/673e951dc1be1a2b1f395a4ee041b5b5 to your computer and use it in GitHub Desktop.
docblock tag to array
<?php
$str ='
/**
* @param integer $int An integer
* @return boolean
* @postParams [display_name, username, about, email, gender, password, confirm_password]
*/
';
if (preg_match_all('/@(\w+)\s+(.*)\r?\n/m', $str, $matches)){
$result = array_combine($matches[1], $matches[2]);
}
$p = $result['postParams'];
$p = str_replace(str_split('[] '), "", $p);
$a = explode(",", $p);
var_dump($a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment