Skip to content

Instantly share code, notes, and snippets.

@hciudad
Created January 27, 2014 20:18
Show Gist options
  • Save hciudad/8656418 to your computer and use it in GitHub Desktop.
Save hciudad/8656418 to your computer and use it in GitHub Desktop.
Using heredocs in a PHP array
// This actually works
$my_array = array(
'foo' => <<< FOO
It's time for
some foo, baby!
FOO
,
'bar' => <<< BAR
Now let's bar it up.
BAR
,
'hello' => 'world'
);
print_r($my_array);
// Array
// (
// [foo] => It's time for
// some foo, baby!
// [bar] => Now let's bar it up.
// [hello] => world
// )
@aezell
Copy link

aezell commented Jan 27, 2014

Weird white-space preservation even without the explicit HEREDOC endings. That's a spicy meatball.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment