Customizing SMF > SMF Coding Discussion

Custom script can a code get some numbers from URL?

(1/1)

MoneyMan87:
I want if possible from this url: http://l2votezone.com/sinfo/123.html get only this ΄123΄ but it's script at other page maybe will be ΄787΄ it's possible to do it? because i have a custom script and it's has punbb but i have connct it with smf and now i have only this problem :)

Ricky.:
Yes, you can use PHP to extract that part url :


--- Code: ---$url = 'http://l2votezone.com/sinfo/123.html';
preg_match('/[\d]{3,6}/', $url, $match);
echo $match[0];

--- End code ---

Should give you :
123

In other words, it will show any number in your url which 3 to 6 digit long. 

There can be other way too, however, this one seems easier.

Navigation

[0] Message Index

Go to full version