Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
String : ID#6 Item name
I want to remove any ID#1 or ID#18 & keep the word after.
ID#1
ID#18
$string = str_replace('ID#', '', $string); $string = substr(strstr("$string"," "), 1);
Is there a more elegant solution?
str_replace
ID#
This might look a bit weird, but its a one liner
$test = "ID#6123234235345asdasdasdasd"; var_dump(ltrim($test, "ID#0..9")); // string(12) "asdasdasdasd"
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
str_replaceis for static content being replaced. Is it always a number afterID#?ID#