1
<?php 

$arr00 = array(1,5,7);
$arr01 = array(9,6,3,$arr00);
$arr02 = array(4,8,12,$arr01);

echo $length = count($arr00);
echo "<br />";

echo $length1 = count($arr01);
echo "<br />";

echo $length2 = count($arr02);
echo "<br />";
for($i = 0; $i < $length; $i++)
    for($j = 0; $j < $i; $j++)
      for($k = 0; $k < $j; $k++){

         echo "<pre>";
    print_r($arr02);
    echo "</pre>";

      }


 foreach ($arr00 as $value)
    {
        echo $value." ";
    }
    foreach ($arr01 as $value1) 
        {
        echo $value1." ";
    }
    foreach ($arr02 as $value2) 
    {
        echo $value2." ";
    }

Notice: Array to string conversion in C:\xampp\htdocs\mywebpage\3dimns.php on line 34 Array 4 8 12 Notice: Array to string conversion in C:\xampp\htdocs\mywebpage\3dimns.php on line 39 Array

ghallu sahb
  • 13
  • 1
  • 3
  • [Reference - What does this error mean in PHP?](http://stackoverflow.com/a/24507107) - Please include a question with your question, not just a code dump and implied debugging request. – mario Jun 10 '15 at 15:28

3 Answers3

3

Your problem starts here:

$arr00 = array(1,5,7);
$arr01 = array(9,6,3,$arr00);
$arr02 = array(4,8,12,$arr01);

The fourth element of both $arr01 and $arr02 is an array, so when you loop over these arrays and try to echo out the value, you will get this message the 4th iteration of the loop.

What exactly do you want to do?

If you want to combine both arrays, you should look into for example array_merge() (although that depends on how you want to handle duplicates):

$arr00 = array(1,5,7);
$arr01 = array_merge( array(9,6,3), $arr00 );
jeroen
  • 91,079
  • 21
  • 114
  • 132
0

This error is because you have an array in your array. Use this code instead of just echoing:

if(is_string($value)) echo $value." ";

For displaying the array in the array, you can add an else case:

else var_dump($value);
Richard
  • 2,840
  • 3
  • 25
  • 37
0

You should start looking into how to resolve this part so things would be easier for you to sort out.

$arr00 = array(1,5,7);
$arr01 = array(9,6,3,$arr00);
$arr02 = array(4,8,12,$arr01);

Why not try array_merge() for your $arr01 so you can have something like

$arr01 = array(9,6,3);
$newArr1 = array_merge($arr00,$arr01);

Then also

$arr02 = array(4,6,12);
$newArr2 = array_merge($$arr02,$arr01);

With the above you'll be having just 3 easy arrays to deal with as

$arr00,$newArr1,$newArr2

You can now execute your other codes easily.

OmniPotens
  • 1,125
  • 13
  • 30