/    Sign up×
Community /Pin to ProfileBookmark

Passing an array to other page

hi,

i am having an array like this..

$array_of_emailids=(“email1″,”email2″,”email3″,”email4″,”email5”,…….);

i want to pass this array to another page (possibly through a form as hidden value if possible) how can i do that???

if it is not possible with a form can u giveme sm other solution…

-ashish

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@shimulJan 28.2006 — You can store it at session $_SESSION . or if you want to use hidden field then use base64_encode($array_of_emailids); and after getting this value you can use base64_decode(); to decode it .

hope this will help You.

Stranger
Copy linkTweet thisAlerts:
@bokehJan 28.2006 — If you don't want to store it as a session you could:

1) Send it as hidden fields:[code=php]<?php
foreach($emails as $k => $v){
echo '<input type="hidden" name="email['.$k.']" value="'.$v.'">'."n";
}
?>[/code]


2) Serialize it and send it as a cookie:[code=php]// set the array cookie
setcookie ('emails', serialize($emails));

// retrieve the array cookie
$emails = unserialize((get_magic_quotes_gpc())?stripslashes($_COOKIE['emails']):$_COOKIE['emails']);
[/code]

I kind of like option 2 the best because a hidden form needs to be posted by the user or javascript (which doesn't matter if it is part of a bigger form) whereas cookies work more seamlessly (although of course they need to be enabled on the UI). Also method 2 would work with strings, arrays, integers, booleans and even NULL values, making it a lot more versitile.

What other methods are there? Anyone?
×

Success!

Help @ashishrathore spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.14,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...