Help: How does PHP use the regular to get floating-point numbers?

Source: Internet
Author: User
' TMap 116.123456,39.123456 '
There are spaces behind the TMap,
I want to get 116.123456
and 39.123456 two floating-point coordinates, how can I get it with a regular?


Reply to discussion (solution)

$str = ' TMap 116.123456,39.123456 ';p reg_match_all ('/[^\s]+/', $str, $match); $numstr = $match [0][1];p rint_r (Explode (', ', $numstr));


Array
(
[0] = 116.123456
[1] = 39.123456
)

$s = ' tmap 116.123456,39.123456 ';p reg_match_all ('/[\d. +/', $s, $r);p rint_r ($r [0]);
Array (    [0] = 116.123456    [1] = 39.123456)

$s = ' tmap 116.123456,39.123456 '; $ar = Preg_split ('/[\s,]+/', $s);p rint_r ($ar);

$str = ' TMap 116.123456,39.123456 ';p rint_r (preg_split ('/[\s,]/', $str));
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.