dexter
dexter

Reputation: 133

preg replace number with dot separator

i want to get value user id and album id with dot as separator

userId.albumId
1284939271971639.838074720820710

mycode

$id = '1284939271971639.838074720820710';

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

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

Upvotes: 0

Views: 80

Answers (1)

ArtisticPhoenix
ArtisticPhoenix

Reputation: 21681

Here is what I would do

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

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

output

ID: 1284939271971639
Album ID: 838074720820710

Sandbox

Upvotes: 1

Related Questions