Hi there guys, I want to remove a random 4 digit number from a string. For example let say we have: $str = "1) Hallo 1536 world!"; $str2 = "2) Hallo to all of my 4728 friends!"; I cant go removing digits between 0-9 cause 1) and 2) will be erased. I want just to remove every number that has 4 digits only. Any suggestions? Thanks in advance! (Probably preg_match ?)
Ididnt see that coming The problem is that i want to remove some strings like: blablabla &# 8217; blablablablablabla blablabla &# 8220; blablabla blablabla &# 8221; blablablablablabla ........ and so on so how am i going to write that script above? $str = preg_replace('&# #[0-9]{4}#;','',$str); I dont believe that is going to work any suggestions?
Nope there are entities with 2-4 digits in them. So how can we transform the above code to remove from 2 to 4 digits instead of only 4?
lol yeap thank you but im not from an English spoken country and my real problem is the above script. Thanks anyway
I understand that. Isnt there a way not to write a 3 lines of code like: $str = preg_replace('/&#\d{4,};/', '', $str); $str = preg_replace('/&#\d{3,};/', '', $str); $str = preg_replace('/&#\d{2,};/', '', $str); Code (markup): but just one to make the work of the three of them?
I do not understand very well but your 3 lines of codes are actually equivalent to $str = preg_replace('/&#\d{2,};/', '', $str); PHP: