Reputation: 327
Im just using the graph.facebook.com code to display photos from an album but i want the user to be able to paste the URL from their album and then using a php regular expression or javascript i would like to remove everything but the album id so i can display the photos.
If a user pastes this to their users MYSQL table:
https://www.facebook.com/media/set/?set=a.10152107362775359.906732.14226545341&type=3
What would be the best way to retrieve only the numbers after a. and before where the next . starts.
basically i need this: 10152107362775359
I know i can get everything that set=
$notclean = 'a.10152107362775359.906732.14226545341';
but now how do i make
$notclean = '10152107362775359';
Thanks in advance :) Jonny
Upvotes: 0
Views: 158
Reputation: 31141
Split it at the periods.
var parts = 'a.10152107362775359.906732.14226545341'.split('.');
This gives you an array
["a", "10152107362775359", "906732", "14226545341"]
Then get the 2nd element of the array
$notclean = parts[1];
For PHP use explode instead of split.
$parts = explode('.', $notclean);
Upvotes: 1