fork download
  1. <?php
  2. $str = '
  3. /**
  4. * This is simple function.
  5. *
  6. * This is big description
  7. * of current function.
  8. *
  9. * @category CategoryName
  10. * @package PackageName
  11. * @author Original Author <author@example.com>
  12. * @author Another Author <another@example.com>
  13. * @copyright 1997-2005 The PHP Group
  14. * @license http://w...content-available-to-author-only...p.net/license/3_01.txt PHP License 3.01
  15. * @version SVN: $Id$
  16. * @param String|Int параметр1
  17. * @param Array параметр2
  18. * @link http://p...content-available-to-author-only...p.net/package/PackageName
  19. * @see NetOther, Net_Sample::Net_Sample()
  20. * @since File available since Release 1.2.0
  21. * @deprecated File deprecated in Release 2.0.0
  22. */
  23. ';
  24. $results = [
  25. 'descr' => []
  26. ];
  27.  
  28. $segments = explode('*', $str);
  29. foreach($segments as $segment) {
  30. if(($segment = trim($segment, '/ '.PHP_EOL)) != '') {
  31. if(strpos($segment, '@') === 0) {
  32. $p = strpos($segment, ' ');
  33. $results[trim(substr($segment, 0, $p), '@')][] = trim(substr($segment, $p));
  34. } else {
  35. $results['descr'][] = $segment;
  36. }
  37. }
  38. }
  39. $results['descr'] = implode(' ', $results['descr']);
  40. print_r($results);
Success #stdin #stdout 0.02s 23524KB
stdin
Standard input is empty
stdout
Array
(
    [descr] => This is simple function. This is big description of current function.
    [category] => Array
        (
            [0] => CategoryName
        )

    [package] => Array
        (
            [0] => PackageName
        )

    [author] => Array
        (
            [0] => Original Author <author@example.com>
            [1] => Another Author <another@example.com>
        )

    [copyright] => Array
        (
            [0] => 1997-2005 The PHP Group
        )

    [license] => Array
        (
            [0] => http://w...content-available-to-author-only...p.net/license/3_01.txt  PHP License 3.01
        )

    [version] => Array
        (
            [0] => SVN: $Id$
        )

    [param] => Array
        (
            [0] => String|Int параметр1
            [1] => Array параметр2
        )

    [link] => Array
        (
            [0] => http://p...content-available-to-author-only...p.net/package/PackageName
        )

    [see] => Array
        (
            [0] => NetOther, Net_Sample::Net_Sample()
        )

    [since] => Array
        (
            [0] => File available since Release 1.2.0
        )

    [deprecated] => Array
        (
            [0] => File deprecated in Release 2.0.0
        )

)