/    Sign up×
Community /Pin to ProfileBookmark

Serializing 2d Arrays

Ok, I have a major complication.

I’m trying to serialize a 2d array using a foreach.

Here’s what I have so far:

[code=php]<td><input type=”text” name=”bpc[‘ . ($i+1) . ‘][bpcname]” value=”‘ . $bpc[‘bpcname’] . ‘” /></td>
<td><input type=”text” name=”bpc[‘ . ($i+1) . ‘][bpcnum]” value=”‘ . $bpc[‘bpcnum’] . ‘” /></td>
<td><input type=”text” name=”bpc[‘ . ($i+1) . ‘][bpcexp]” value=”‘ . $bpc[‘bpcexp’] . ‘” style=”width: 90px;” /></td>[/code]

There’s the input fields.

Now for the serialization…I really can’t seem to figure it out. I have tried this:

[code=php]
foreach($_POST[‘bpc’] as $key => $value){
echo ‘<pre>’;
print_r($bpc);
echo ‘</pre>’;

$bpc[count($bpc)] = $value;

$bpc = serialize($bpc);
echo $bpc;
}[/code]

I know I’m way off on this though ?.

Anyone know how I can go about this? I’m VERY confused ?.

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @tgrk35 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.17,
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,
)...