Simple problem: php uses regular expressions to filter the format specified in the string and defines it as an array format: [English letters, numbers, {numbers}] for example: $ str = "this is a [pic, {0}] image, which is a description of [desc, {2}] "; replace" [pic, {0}] "and" [desc, {2}] "is defined as an array after being filtered out using regular expressions, and then the brackets are filtered out to become a simple question of" pic, {0, php uses regular expressions to filter the specified format in a string and defines it as an array.
Format: [English and numbers, {numbers}]
For example: $ str = "this is a [pic, {0}] image, and this is a description of [desc, {2}]";
Filter "[pic, {0}]" and "[desc, {2}]" in the above string using regular expressions and define them as arrays. then, filter out the brackets, to "pic, {0}" and "desc, {2 }".
The final result is:
$ ArrStr = array ();
$ ArrStr ["[pic, {0}]"] = pic, {0 };
$ ArrStr ["[desc, {2}]"] = desc, {2 };
What I want is to take out the specified string format and define it as an array, and then assign a value to the string in the format, "$ arrStr [] = pic, {0 }; "or" $ arrStr [0] = desc, {2}; "is not the expected result.
The names of the objects under the array are to be named based on the retrieved format. the values are filtered out using regular expressions.
------ Solution --------------------
$ Str = "this is a [pic, {0}] Image. this is a description of [desc, {2}]";
$ ArrStr = array ();
Preg_replace ('/\ [(. + ?) \]/E', '$ arrStr ["$0"] = "$1"', $ str );
Print_r ($ arrStr );
------ Solution --------------------
$ Demo = '/\ [([a-zA-Z \ d]. + ?), (\ {\ D + \}) \]/e ';