Last active
March 23, 2022 16:54
-
-
Save cmd05/673e951dc1be1a2b1f395a4ee041b5b5 to your computer and use it in GitHub Desktop.
docblock tag to array
This file contains 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
<?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