In my php application user able to enter the tags(like here while ask question). I assume it will be regexp, and I used one - mb_split('\W+', $text) - to split by non-word characters.
But I want to allow users to enter characters like "-,_,+,#" etc which are valid ones to be in url and are common.
Is there exiting solutions for this, or may be best practicles?
thanks.
The split() method splits a string into an array of substrings. The split() method returns the new array. The split() method does not change the original string. If (" ") is used as separator, the string is split between words.
I use split(" ") for whitespace and use split(/(<[^>]*>)/) for html tag in string.
Definition and Usage. The str_split() function splits a string into an array.
Use the explode() function and separate by either spaces or commas. Example:
$string = 'tag1 tag-2 tag#3';
$tags = explode(' ', $string); //Tags will be an array
Split by whitespace \s+
instead.
Split on \s+ (whitespace) instead of \W+ (non-alphanumeric).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With