# Exploding an array

**URL:** https://forum.kirupa.com/t/exploding-an-array/270615
**Category:** programming
**Created:** [September 11, 2008, 4:04pm UTC](https://forum.kirupa.com/t/exploding-an-array/270615 "2008-09-11T16:04:56Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![imagined](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@imagined](https://forum.kirupa.com/u/imagined)
#### Post date: [September 11, 2008, 4:04pm UTC](https://forum.kirupa.com/t/exploding-an-array/270615/1 "2008-09-11T16:04:56Z")

</div>

I pull this data from a database:

* * *

Some explanation goes here

\<CODE\>  
echo ‘this is code’;  
\</CODE\>

## And then I continue the explanation here

**I want to put this as an array, like this:**  
[0] = Some explanation goes here  
[1] = \<CODE\>echo ‘this is code’;\</CODE\>  
[2] = And then I continue the explanation here

I tried

```php

$i=0;
$article = explode('

```

', $article);  
foreach($article as $key =\> $value)  
{  
$array[$i] = $value;  
$i++;  
}

```auto

But it gives me this:

[0] = Some explanation goes here
[1] = &lt;CODE&gt;echo 'this is code';&lt;/CODE&gt;And then I continue the explanation here

How can I get the explanation chunks and the CODE chunks in array elements? I guess probably another explode, I have tried but can't make it work. 

I'm trying to do this because I want to apply htmlentities to the CODE chunks.

Note: I'm really using brackets instead of &lt; and &gt; but the forum would parse it as code.
```
