I have one string
string = "example string is cool and you're great for helping out A string is a sequence of characters"
I want to insert a line break every words in array so it returns this:
const cars = [" is cool", "great for", "out"];
string = 'example string n
is cooln
and you'ren
great forn
helpingn
outn
A string is a sequence of characters'
I am working with variables and cannot manually do this. I need a function that can take this string and handle it for me. and Between two array words is a newline
Thanks!!
2
Answers
You can try the following function:
Use
str_replace()