Well, I have following array and variables and it's output is bellow :
`print_r($menu_ex_qnt);`
Array
(
[0] => 1
[1] => 2
)
print_r($menu_extra_item_name);
Array
(
[0] => 238
[1] => 239
)
$final_ex = array_combine($menu_ex_name, $menu_ex_qnt);
print_r($final_ex);
Array
(
[238] => 1
[239] => 2
)
echo $final_ex = serialize($final_ex);
a:2:{i:238;s:1:"1";i:239;s:1:"2";}
Now, I am inserting this $final_ex
variable to database.
But when I get this variable from database and try to unserialize
it then it's showing me following error message :
echo unserialize($p_ext_items);
Note : This $p_ext_items contain the serialize string e.g: a:2:{i:238;s:1:"3";i:239;s:1:"1";}
Notice: unserialize(): Error at offset 11 of 54 bytes .......
why ?
What I actually want
There are 2 variables $menu_ex_qnt
and $menu_extra_item_name
. I want to save these 2 variables value
not key
to the database. So that, in final variable there will be key
and value
pair.
For e.g:
238 => 1
239 => 2