1

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.

8
  • $request_control['personal_task'] = output from multiple input one step before (is array) Commented Oct 2, 2014 at 18:08
  • 2
    I like miltiple inputs Commented Oct 2, 2014 at 18:09
  • Start with the purpose. Why do you need this? Commented Oct 2, 2014 at 18:09
  • 2
    @Brian miltiple is my new fav word Commented Oct 2, 2014 at 18:11
  • 1
    <input type="hidden" name="miltiple" value="<?php echo implode(',', $array); ?>"> then explode() the value after it's submitted. Commented Oct 2, 2014 at 18:13

3 Answers 3

4

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....

Sign up to request clarification or add additional context in comments.

Comments

0

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; ?>

Comments

0

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']); ?>" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.