counter variable is not incrementing
<p>I have a counter variable that is for the id or number of an item in an array. That and the content to be added to an array takes up a position in another array. This other array is thus a 2D array.</p>

<p>Basically what I am doing is taking content from one array, which eventually will be dynamically created and added to, and putting that into another array. And then putting that array into a storage array.
For what I am doing, I have to do it this way. Apologies.</p>

<p>What I'm wondering if why my counter variable that increment only increments once as is equal to one when I print_r the array that it and the content i'm adding is a part of.</p>

<p>When I run this code, the structure I should see is:</p>

<pre><code>1, 1's content
2, 2's content
3, 3's content
</code></pre>

<p>But what I am seeing is:</p>

<pre><code>1, 1's content
1, 2's content
1, 3's content
</code></pre>

<p>Why isn't my counter variable who's value is later given to $id not incrementing and how can I get it to increment.
The structure that is set up with the taking from one array, constructing another, and putting that into another array, and then recursively adding the rest of the content pretty much has to stay. I don't have much freedom to change the code.
I just can't figure out why the counter variable isn't incrementing.</p>

<p>Here is the code:</p>

<pre><code>$counter = 0;
$added_text = array();
$addMe = array("orange is the keyword of the day. Tomorrows is mop.", "I do not think you understnad how much I want it. I need it and it will happen.", "I love all sorts of music. Do I consider it a gift, I am not sure. That is all I know.");

function thing($contents, $addMe)
{
    $counter++;
    $text = strip_tags($contents);

    $id = $counter;
    $content = array(
        'id'      =&gt; $id,
        'content'     =&gt; $text
    );

    print_r($content);
    echo "&lt;br /&gt;&lt;br /&gt;";
    array_push($added_text, $content);

        foreach($addMe as $text){
            if(!in_array($added_text, $text)){
                sleep( 1 );
                thing($text, $addMe);
            }
        }
}

thing('hello i am the text 1 as in the text of the first document', $toAdd);
</code></pre>
