-5

I have a item that gives me a result of string(26) "cake1 cake2 cake3 cake4"

The cake result comes from $_POST()

What would be the best way to make it so the final result is like:

cake1 cake2

Jess McKenzie
  • 8,345
  • 27
  • 100
  • 170

2 Answers2

1

You just need to replace the spaces with <br>'s?

echo str_replace(' ', '<br />', $_POST['cake_list']);

Of course you should sanitize the POST, but this is a quick example for you.

Ryan Kempt
  • 4,200
  • 6
  • 30
  • 41
0

Let's say we have a string like this

$str = "cake1 cake2 cake3 cake4";

convert your string to array like this

$arr = exploade(" ",$str);

show the elements of the array with <br> tag like this

foreach ($arr as $value)
   echo $value . "<br>";
Khalid
  • 4,730
  • 5
  • 27
  • 50