PHP foreach() loop
<pre><code>$string = "The complete archive of The New York Times can now be searched from NYTimes.com " //the actual input is unknown, it would be read from textarea  

$size = the longest word length from the string 
</code></pre>

<p>I assigned and initialized array in for loop, for example array1, array2 ....arrayN, here is how i did</p>

<pre><code>for ($i = 1; $i &lt;= $size; $i++) {
    ${"array" . $i} = array();
}
</code></pre>

<p>so the $string would be divided in the length of the word</p>

<pre><code>$array1 = [""];
$array2 = ["of", "be", ...]
$array3 = ["the", "can", "now", ...] and so on 
</code></pre>

<p>So, my question is how to assign in simple for loop or foreach loop $string value to $array1, $array2, $array3 ....., since the input text or the size of the longest word is unknown </p>