Support

Account

Home Forums General Issues Is there any problems with saving PHP arrays in a text field ?

Helping

Is there any problems with saving PHP arrays in a text field ?

  • Hi,

    I use the Free version of ACF and it’s awesome, really.
    My users are allowed from a front-end page to add professionnal experiences to thir profile. Each experience creates a php array and is itself added to a big array that regroups all of them.
    Next, this array is saved in a custom field that got the type ‘text’.

    It works pretty well for now, but i just want to know if it could cause issues in the database ?
    I know that i could do that with the premium ACF version with repeater field but the person that charged me of the developpement doesn’t want to pay a plugin (do not judge lol).

    Thanks all !

  • If you try to store a value that is an array in WP, WP will automatically serialize that array. When you get that value WP will automatically unserialize the array and it will not work as a text field.

    If you want to store and array as a text value then you must manipulate the array before inserting it into the DB, for example by using json_encode()

Viewing 2 posts - 1 through 2 (of 2 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.