HI, I have t开发者_如何学编程hese strings:
#05#, #45#, #785#
...etc
I need to get the id so #01544# become 01544. How can I do?
Thanks!
echo str_replace("#", "", "#05#, #45#, #785#");
more info at:
http://php.net/manual/en/function.str-replace.php
Use this:
preg_replace('(#([0-9]+)#)', '\1', '#05#, #45#, #785#');
Try
$str = trim('#01544#', '#');
Why not just use str_replace
? E.g.
$string = str_replace('#', '', $string);
For simple patterns like this, regex is never necessary.
You can just use str_replace
:
$id = str_replace("#", "", $your_variable);
精彩评论