0

Alright so for some reason even with implode in place I am getting an error saying Array to string Conversion on this line

echo implode($weather['list'][0]['weather']);

Notice: Array to string conversion in

5
  • 2
    could we please see a bit more of your code and what exactly you are trying? is it a 3 or 4 dimensional array? Commented Nov 28, 2016 at 19:15
  • Well that what I am getting from the openweather.org, its a 3D array. Commented Nov 28, 2016 at 19:17
  • even without the other code, i can tell that a multi-dimensional array is not going to work where $array = array('lastname', 'email', 'phone'); $simple = implode($array); does. (can't imagine why we would want "lastnameemailphone" though) Commented Nov 28, 2016 at 19:19
  • This is what I get from the var dump (atleast 1 part of it, its kinda big but it doesnt expand bigger than this) pastebin.com/KteUqtqc Commented Nov 28, 2016 at 19:25
  • whats the content of weather ? what are you trying to obtain? Commented Nov 28, 2016 at 19:49

1 Answer 1

2

I got this notice while trying to implode an array with inner dimensions:

$arrayWithInnerDimensions = [
    'first_dimension' => [
            'a',
            'b' => [1,2],
            'c',
        ]
    ];

echo implode($arrayWithInnerDimensions['first_dimension']); //notice

echo "\n\n";

$arrayWithoutInnerDimensions = [
    'first_dimension' => [
            'a',
            'b' => 'd',
            'c',
        ]
    ];

echo implode($arrayWithoutInnerDimensions['first_dimension']); //ok
Sign up to request clarification or add additional context in comments.

2 Comments

I cant really modify the array as its sent from an outside source so I dont see what are you trying to tell me with this
I suppose You need something like that implode multidimensional arrays

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.