Reputation: 21
Can I do something like this?
<input type="hidden" name="for_person[]" miltiple="multiple" value="<?php echo $request_control['personal_task']; ?>">
I guess not, cause output in value=""
tag is "Array" of course.
Upvotes: 1
Views: 229
Reputation: 927
You can improvise for something like this:
<?php foreach($request_control['personal_task'] as $task): ?>
<input type="hidden" name="for_person[]" multiple="multiple"
value="<?= $task ?>">
<?php endforeach; ?>
Upvotes: 0
Reputation: 27845
You could use json_encode
or serialize
to produce a string outof the array and pass via the hidden input. At server you can get it back via json_decode
or unserialize
.
Like
<input type="hidden" name="for_person" value="<?php echo json_encode($request_control['personal_task']); ?>" />
or
<input type="hidden" name="for_person" value="<?php echo serialize($request_control['personal_task']); ?>" />
Upvotes: 0
Reputation: 32340
You can set miltiple values for a name using miltiple inputs:
<input type="hidden" name="for_person[]" value="1">
<input type="hidden" name="for_person[]" value="2">
Just loop over your array using foreach
or while
or for
....
Upvotes: 4