Issues with text white space that needs to be replaced with \n\n

Viewed 35

This is an example of text I receive from my vue front end to the Laravel back end(I logged the output).

Creating a successful online marketing campaign can be daunting, but with the right strategy and execution, it's definitely achievable. Here are five tips to help you get started:

1. Set realistic goals. Don't try to scale your business overnight by launching a massive online marketing campaign. Start small and gradually increase your efforts over time as your business grows. Aim for modest objectives that you can realistically achieve, such as increasing website traffic by 10 percent or increasing leads generated by 20 percent.

2. Plan your time wisely. It's important to set aside adequate time each week to devote to your online marketing campaign. If you're working on multiple campaigns simultaneously, make sure to allocate sufficient time for each one so that they don't overlap or conflict with one another.

3. Utilize effective tools and resources. There are many helpful tools and resources available online that can help you create effective online marketing campaigns. For example, Google AdWords is an advertising platform that allows you to place ads on Google search results and across other websites. There are also several free tools available online that can help you track your website's performance and measure the effectiveness of your campaigns.

4. Build relationships with key partners and collaborators. Working together with key partners and collaborators can boost the success of your online marketing campaign by providing valuable feedback, exposure, and support in exchange for promotional materials or links back to their websites or blogs. For example, if you're promoting a new product launch, partnering with influential bloggers who write about similar topics could provide valuable coverage leading up to the launch date.

5. Be persistent and consistent with your efforts. Don't give up after initial failures – persistence is key when it comes to creating successful online marketing campaigns! Keep trying new strategies until you find ones that work better than the previous ones, then stick with them long-term in order to see results.  

In order for me to be able to use it in another API, I need to send it like this:

  1. Set realistic goals. Don't try to scale your business overnight by launching a massive online marketing campaign. Start small and gradually increase your efforts over time as your business grows. Aim for modest objectives that you can realistically achieve, such as increasing website traffic by 10 percent or increasing leads generated by 20 percent.\n\n2. Plan your time wisely. It's important to set aside adequate time each week to devote to your online marketing campaign. If you're working on multiple campaigns simultaneously, make sure to allocate sufficient time for each one so that they don't overlap or conflict with one another.\n\n3. Utilize effective tools and resources. There are many helpful tools and resources available online that can help you create effective online marketing campaigns. For example, Google AdWords is an advertising platform that allows you to place ads on Google search results and across other websites. There are also several free tools available online that can help you track your website's performance and measure the effectiveness of your campaigns.\n\n4. Build relationships with key partners and collaborators. Working together with key partners and collaborators can boost the success of your online marketing campaign by providing valuable feedback, exposure, and support in exchange for promotional materials or links back to their websites or blogs. For example, if you're promoting a new product launch, partnering with influential bloggers who write about similar topics could provide valuable coverage leading up to the launch date.\n\n5. Be persistent and consistent with your efforts. Don't give up after initial failures – persistence is key when it comes to creating successful online marketing campaigns! Keep trying new strategies until you find ones that work better than the previous ones, then stick with them long-term in order to see results.

I had to remove the code block or you would not have been able to see the "\n\n"

I cannot manage to remove the white space between each paragraph and add \n\n instead

Any idea how to do this please?

Thank you!

1 Answers

use preg_replace($pattern, $replacement, $string); i think you want to remove space and replace it with line break, if it's the case :

$str = preg_replace('^[ \t]*$', '\n\n', $str);
Related