Support

Account

Home Forums General Issues Help With Creating An Array

Unread

Help With Creating An Array

  • I want to create an array from the content provided in 3 different checkboxes. I am using WP Frontend in WordPress, to create a form that has different multiselect boxes for different categories.

    For example:

    **Category 1:** Tags: 45,78,97
    **Category 2**: Numbers: 3,7,9
    **Category 3:** Marks: 4,8,12

    When Selected, I would like to create an array that would look like this:

    Array
    (
    [tags] => Array
    (
    [0] => Array
    (
    [0] => 45
    [1] => 78
    [2] => 97
    )
    )
    [numbers] => Array
    (
    [0] => 3
    )
    [marks] => Array
    (
    [0] => 18
    )
    )

    Then I would like to serialize it, which would look like this:

    a:3:{s:4:”tags”;a:1:{i:0;a:3:{i:0;i:45;i:1;i:78;i:2;i:97;}}s:7:”numbers”;a:1:{i:0;s:1:”3″;}s:5:”marks”;a:1:{i:0;s:1:”18″;}}

    Any advice on the best way of creating this would be massively appreciated.

    Thanks

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.