Skip to content

Instantly share code, notes, and snippets.

@amberlex78
Created September 2, 2015 05:33
Show Gist options
  • Select an option

  • Save amberlex78/9cfe31220803348e033a to your computer and use it in GitHub Desktop.

Select an option

Save amberlex78/9cfe31220803348e033a to your computer and use it in GitHub Desktop.
<?php
// Поиск цены в строке
// Число типа: 27.30 или 33,56
preg_match('/[0-9]*[\.,]?[0-9]/', $text, $matches);
if (isset($matches[0])) {
$price = str_replace(',', '.', $matches[0]);
} else {
$price = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment