In general, it’s impossible to parse a string, which can be of several types:

friends$id friends$id_$mask friends$id#$mode friends$id_$mask#$mode 

In the word friends it can sometimes be _ friends_cnt$id .

$id && $mask && $mode are numbers.

  • Your question is a little not clear task. Provide test data. Something like func ("friends $ 444 $ 55555) =>" 444 "," 55555 "and the like. - KoVadim
  • $ key = "friends50"; $ key = "friends50_1"; $ key = "friends50 # 2"; $ key = "friends50_1 # 2"; $ key = "friend_cnt50"; The key can be any of the above listed like this: preg_replace ("/ ([az] +) ([0-9] +) _ ([0-9] +) # ([0-9] +) / ies" , "\ $ this-> keys ('\\ 1', '\\ 2', '\\ 3', '\\ 4');", $ key); but it only defines the key "friends50_1 # 2"; How to make it so that any of the above keys can be parsed and sent to the function; it is not necessary that preg_replace can be parsed any way. - Alex3327
  • The fact that you entered the input data is good, and what output should be for them? Not quite clear. In the case of "friends50_1 # 2", the friends array, 50,1,2 is understandable. And in the case of friend_cnt50 - what should be? - KoVadim
  • Also, only friend_cnt, 50 I showed this line only because there is an underscore, because it must be taken into account in the condition. - Alex3327

0