How to Expand $ str layers based on $ hello data? How to Expand $ str layers based on $ hello data? PHPcode & lt ;? Php $ my_arrarray (); $ str & quot; DIR_FS_AAA.DIR_WS_CLASSES & quot; $ helloarray (& quot; DIR_FS_AAA & quot; how to layer $ str based on $ hello data?
How to Expand $ str layers based on $ hello data?
PHP code
"DIR_WS_TEMPLATE. 'primary des/'"," DIR_WS_CLASSES "=>" DIR_WS_ADMIN. 'helloworld' "," DIR_WS_TEMPLATE "=>" template/"," DIR_WS_ADMIN "=>" admin/"); // how to obtain the result array: $ my_arr = array ("DIR_FS_AAA. DIR_WS_CLASSES "," DIR_WS_TEMPLATE. 'Des /'. DIR_WS_TEMPLATE. 'primary des/'"," template/primary des/admin/primary des/");?>
------ Solution --------------------
PHP code
$my_arr[] = $str;$tmp = preg_replace("/[A-Z_]+/e", "\$hello['\\0']", $str);$my_arr[] = $tmp;$tmp = preg_replace("/[\"']?\s*\.?\s*([A-Z_]+)\s*\.?\s*[\"']/e", "\$hello['\\1']", $tmp);$my_arr[] = $tmp;//testprint_r($my_arr);/**Array( [0] => DIR_FS_AAA . DIR_WS_CLASSES [1] => DIR_WS_TEMPLATE.'includes/' . DIR_WS_ADMIN.'helloworld' [2] => template/includes/admin/helloworld')/**/