how to pass array from one page to another php page
Moderator: General Moderators
how to pass array from one page to another php page
how to pass array from one page to another php page
- protokol
- Forum Contributor
- Posts: 353
- Joined: Fri Jun 21, 2002 7:00 pm
- Location: Cleveland, OH
- Contact:
When setting the url you do this:
When you retrieve the array (which you serialized), then when you access it you do this:
This will convert the value back into an array, which it started as to begin with. Then you just treat $array as you would a normal array.
Code: Select all
<?php
$temp = serialize( $info );
?>
<a href="detail.php?var=<?php echo $temp ?>">Code: Select all
<?php
$array = unserialize( $_GET['var'] );
?>thanks a lot, protokol
I did what you wrote above, but I still get a problem, the array after I serialize is
"a:3:{i:0;a:6{i:0;i:1;s:2:" ID";i:1;i:1;s:30:"news1 ";s:5:"title";s:30:"news1 ";i:2;s:200:"content1 ";s:7:"content";s:200:"content1 ";}i:1;a:6:{i:0;i:2;s:2:"ID"; ".......
but what I got in the $_GET is :
" a:3:{i:0;a:6:{i:0;i:1;s:2:"
I think the " mark before ID make it PHP stop scanning the whole string, is there any solution to solve this?
I did what you wrote above, but I still get a problem, the array after I serialize is
"a:3:{i:0;a:6{i:0;i:1;s:2:" ID";i:1;i:1;s:30:"news1 ";s:5:"title";s:30:"news1 ";i:2;s:200:"content1 ";s:7:"content";s:200:"content1 ";}i:1;a:6:{i:0;i:2;s:2:"ID"; ".......
but what I got in the $_GET is :
" a:3:{i:0;a:6:{i:0;i:1;s:2:"
I think the " mark before ID make it PHP stop scanning the whole string, is there any solution to solve this?