Re: array_slice and for loop problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Are you trying to put each return from array_slice into $output as an array? You need to replace $output = array_slice... with $output[] = array_slice...

Also, you cannot just echo an array (even of characters). It must be a string, or else echo will only produce the output 'Array'.

Hope this helps,
-Connor McKay

Rodney Green wrote:
Hello,

I'm using a for loop to iterate through an array and slice parts of
the array and add into another array.

When array_slice is called the variable $i is not being substituted
with the current value of
$i and the $output array is empty after running the script. Can
someone look at the code below and give me a clue as to why this
substitution is not happening? If I uncomment the "echo $i;" statement
the value of $i is printed just fine.

Thanks,
Rod

Here's my code:


$number = count ($int_range[start]);
       //echo $number;
       for ($i = 0; $i <= $number; $i++) {

      //echo $i;

           $output = array_slice ($textArray, $int_range[start][$i],
$int_range[end][$i]);

           }




           foreach ($output as $value) {

                      echo $value;
                        }

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux