When I serialize an array consisting of 3-4 multidimensional arrays, everything happens to be normal, when I serialize from an array in which there are more than 6 multidimensional arrays, everything seems to be normal, but I cannot deserialize them. I give an example of the array that does not want to deserialize:

a:10:{ i:0;a:4:{ i:0;s:79:"Суп овощной с фрикадельками из мяса курицы";i:1;s:1:"8";i:2;i:400;i:3;s:2:"50"; } i:1;a:4:{ i:0;s:91:"Мясо 'Атаман' (свинина, помидор, лук, сыр, чесн, м-з)";i:1;s:2:"11";i:2;i:902;i:3;s:2:"82"; } i:2;a:4:{ i:0;s:10:"Самсы";i:1;s:1:"5";i:2;i:175;i:3;s:2:"35"; } i:3;a:4:{ i:0;s:14:"Булочка";i:1;s:1:"5";i:2;i:100;i:3;s:2:"20"; } i:4;a:4:{ i:0;s:27:"Кисель ягодный";i:1;s:1:"1";i:2;i:35;i:3;s:2:"35"; } i:5;a:4:{ i:0;s:22:"С-т 'Малибу'";i:1;s:1:"7";i:2;i:294;i:3;s:2:"42"; } i:6;a:4:{ i:0;s:74:"Творожная запеканка со сгущёным молоком";i:1;s:1:"5";i:2;i:210;i:3;s:2:"42"; } i:7;a:4:{ i:0;s:59:"Бульон с куриным мясом и зеленью";i:1;s:1:"1";i:2;i:70;i:3;s:2:"70"; } i:8;a:4:{ i:0;s:13:"с рисом";i:1;s:1:"1";i:2;i:20;i:3;s:2:"20"; } i:9;a:4:{ i:0;s:28:"Сосиска в тесте";i:1;s:1:"1";i:2;i:40;i:3;s:2:"40"; } } 
  • 2
    Yes, this can not be. Throw code somewhere in your script! - Artem

1 answer 1

Perhaps this is because of single quotes in words.
Try serializing htmlspecialchars(serialize($array),ENT_QOUTES)
And when unserialize(htmlspecialchars_decode($serialize_array)) anserialization unserialize(htmlspecialchars_decode($serialize_array))

  • 3
    Have you been to htmlspecialchars last time an array of shoving? - Sh4dow
  • @ Sh4dow beat me :) - Artem
  • Agreed, changed the answer - Maksym Prus
  • At the same time, you can still encode in base64, and then decode it. Just in case. - ReinRaus
  • Thanks helped! - blud