How to split session values?
I am getting error like "Notice: Array to string conversion in PHP" in session;
How to solve that?

Recommended Answers

All 3 Replies

Depends on the structure of the array and the data type, you could use implode() to flat the array to a string:

$a = ['a' => 123, 'b', TRUE, 'c', NULL, 'd', 'e' => [1,2,3]];
print_r(implode(', ', $a));

# returns 123, b, 1, c, , d, Array

But as you see: you loose the index key a, with booleans and null you get a conversion and the nested array is converted to Array, not showing the data.

Split on what condition? Give an example of a session variable you have and how would you like to have it split.

Member Avatar for diafol

@Antony

I think I've mentioned this before, but please give full information in your questions. Many of the questions you've posed so far have seen contributors asking to see your code and for you to explain further. I do not understand why you do not provide full information or your code in the opening post. It would save a lot of time - for everybody.

Please read: https://www.daniweb.com/web-development/php/threads/435023/read-this-before-posting-a-question

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.