All you need is letters and possibly numbers after letters to remove. Line: 644.99 USD PM Leave only: 644.99 numbers can be separated by a space of type 10 100.69 Therefore, to clean out the number will not work out. Instead of USD PM it can be Privat24 UAH Russian letters should also be taken into account. BTC can also

Thank!

Closed due to the fact that the essence of the question is incomprehensible by the participants aleksandr barakin , Grundy , Bald , Streletz , D-side 12 Jul '16 at 15:28 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Have you tried to solve the problem yourself? What options did you find, why didn't they suit you? - Alexey Ukolov
  • why do you then think about the letters. rip out numbers, periods and spaces. after that clear the variable of spaces - Mike
  • How then can this miracle be realized? Give an example please, tk. with regulars special e slacious ( - Vladimir
  • one
    I vote for the closure of this question, since the answer to it can hardly be useful to anyone other than the author of the question. - aleksandr barakin

2 answers 2

<?php //$value = "644.99 USD PM"; $value = "13 644.99 Приват24 UAH"; preg_match('!^([\d.,\s]+)?!',$value,$out); $value = preg_replace('![^0-9.,]!','', $out[1]); echo $value; 
  • added an example, was not too lazy to check - iosp

$str=str_replace(" ","",preg_replace("/(\\d[0-9., ]*)/","$1",$str, 1)) First we get 1 number (including spaces), then delete the spaces