php - try to extract data from string in structured format -
I am trying to parse some data in PHP, but I'm not sure what the data format is. It appears to be a type of JSON, but I'm not sure.
Here's an example; "Name" "" "{}" group "" "{}" group "" trusted "}" J883Dd "{" name " "Foo Bar" "Reject" {} "" {} "Group" Regular "Allow}}
I can add the person's nickname and group to my ID ( kFj394 < / Code> and
J883Dd
in this example)
If anyone knows how I can complete it, or even What data format is this, I appreciate the help. Thanks.
I do not know what your format is. It is definitely not JSON. Regular expression is probably your only shot:
$ block = ''; // The text you pasted goes here. Foreach (['kFj394', 'J883Dd'] as the $ id) {$ nameSearchPattern = '/' $ id. ' "[\ N \ t \ s \ w {}"] *? Name "\ s +" (. +) "/ '; $ GroupSearchPattern = '/' '. $ Id. ' "[\ N \ t \ s \ w {}"] *? Group "\ s +" (. +) "/ '; Preg_match ($ nameSearchPattern, $ block, $ name matches); Preg_match ($ Group Search Parton, $ block, $ group mat); $ name = $ names matches [1 ]; $ Group = $ group matches [1]; echo "$ id name is name $ \ n"; echo "group $ $ group for $ id \ n";}
Comments
Post a Comment