用点分隔符代替数字

时间:2019-02-21 02:37:36

标签: php

我想使用点号作为分隔符来获取有价值的用户ID和相册ID

userId.albumId
1284939271971639.838074720820710

mycode

$id = '1284939271971639.838074720820710';

uid = preg_replace ('/d+./','',$id);

aid = preg_replace ('/.d+/','',$id);

1 个答案:

答案 0 :(得分:1)

这就是我要做的

$id = '1284939271971639.838074720820710';
preg_match('/(?P<id>\d+)\.(?P<album_id>\d+)/', $id, $match);

$id = $match['id'];
$album_id = $match['album_id'];

输出

ID: 1284939271971639
Album ID: 838074720820710

Sandbox