Jump to content

multiarray value display


brainstem

Recommended Posts

All I am trying to do is get all the text from a file and display them like this:

your not
good enough
at php
yet to
figure this
crap out
brainstem growl

This is what I have, I can not for the life of my figure out a way around array_values
$massive = str_word_count(file_get_contents('massive.txt', 1));
$massivechunk = array_chunk($massive, 2, FALSE);
print_r(array_values($massivechunk));
for ($i = 0, $c = 10; $i < $c; $i++) {
foreach (($massivechunk[$i]) as $domassive) {
echo $domassive;
echo "<br>";
}
}

Link to comment
Share on other sites

Assuming "massive.txt" contains
[quote]your not good enough at php yet to figure this crap out brainstem growl[/quote]
then
[code]
<?php
$massive = explode(' ', file_get_contents('massive.txt', 1));
$massivechunk = array_chunk($massive, 2);
foreach ($massivechunk as $chunk)
{
    echo join(' ',$chunk).'<br/>';
}
?>[/code]
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.