I have bio information inside a variable:
$bio = ‘text, text, text…’;
I trim that text and use rtrim php function at the end
trim($bio);
rtrim($bio,',.;:- _!$&#');
The problem is that sometimes the bio information has a structure like this:
$bio = 'hello, i am jason!and i like cars,sports,beer and boats, tv, papers.';
Is there a way to add spaces when two words separated by punctuation marks are not delimited by spaces? Like “i am jason!and” or “cars,sports,beer”
$bio should be:
$bio = 'hello, i am jason and i like cars, sports, beer and boats, tv, papers.';
Thank you!
You could always have a loop that checks each index of the string, and if it equals one of the given punctuations you have, create a new string such as
It’s bulky for sure but should get the job done.