Skip to content
Advertisement

Tag: split

Split string by last character and save to array?

I have several strings that look like: longname1, anotherlongname2, has1numbers2init3 I would like to use str_split to split off the last character of the strings. Eg: I can get the number alone using substr($string, -1); but need to find an efficient way of retrieving the remainder of the string. I have tried: but of course this doesn’t work. Would anyone

strpos(): Empty needle WordPress Plugin

I’ve just finished building my first plugin and have tested it with various plugins on my personal site with no errors. However some users are saying the plugin is causing the following errors for them: strpos(): Empty needle in /west/XXXXX/public_html/wp-content/plugins/bot-block/bot-plugin.php on line 200 On line 200 I have this: Now I can’t see a problem with that line so I’ll

Split string into 2 letters

I am trying to split a string into 1, 2 and 3 segments. For example, i currently have this: Which works well on 1 character splitting, I get: However when I try: I get: Is there a way so that I can output this? : and then also with 3 characters like this? Answer Here it is: PHPFiddle Link: http://phpfiddle.org/main/code/1bvp-pyk9

Advertisement