-2

why the OpenServer displays the code in a string but not in the column as indicated in the light image. I do everything the same, but I have everything on the line? please help me, what am I doing wrong?

enter image description here

this is my code:

enter image description here

and this is my output and all one line:

enter image description here

but it should be like this[original of the required output]

enter image description here

Johannes
  • 64,305
  • 18
  • 73
  • 130
  • Column? What column are you talking about? – u_mulder Sep 23 '18 at 11:39
  • 3
    please dont use images for your code, chose instead to put your code in the body of the question. – YvesLeBorg Sep 23 '18 at 11:41
  • 1
    Possible duplicate of [Making PHP var\_dump() values display one line per value](https://stackoverflow.com/questions/10116063/making-php-var-dump-values-display-one-line-per-value) – mickmackusa Sep 23 '18 at 12:14

1 Answers1

1

You have var_dump($x) in there two times, which will display the array as a string like in your image. But the echo $x[0] is displayed/echoed correctly in between those two - as "18".

If you want to echo all values of the array, you need a foreach loop, like

foreach($array as $value) { 
  echo "<p>".$value."</p>"; 
}

EDIT AFTER COMMENT:

Put the arrays into pre tags and use print_r($x); instead of var_dump($x), like

<pre>print_r($x);</pre>

Johannes
  • 64,305
  • 18
  • 73
  • 130