I don’t understand how to parse the line below into variables for further use.
Analgin usual capsules 300 mg, 20 pcs.
- $ name = "Analgin"
- $ type = "normal"
- $ dosage = "300mg capsules"
- $ count = "20 pcs"
PS I did not find suitable topics
I don’t understand how to parse the line below into variables for further use.
Analgin usual capsules 300 mg, 20 pcs.
PS I did not find suitable topics
It is possible so: $ a = explode ("", $ str);
капсулы 300мг and 20 шт will be divided into different array elements - teranCan be parsed with regular expressions
$str = 'Анальгин обычный капсулы 300 мг, 20 шт.'; preg_match_all('~\pL+(?:\s\d+\s\pL+\S)?|\d+\s\pL+\S~u', $str, $arr); list($name, $type, $dosage, $count) = $arr[0]; echo "$name $type $dosage $count"; Source: https://ru.stackoverflow.com/questions/883385/
All Articles