Support

Account

Home Forums General Issues How to prevent a leading whitespace?

Solving

How to prevent a leading whitespace?

  • Hi,

    I have some text input fields which are directly referenced in custom SQL queries.

    How can I prevent leading whitespaces from being committed to those field’s meta values, in the first place?

    Please note, I am aware that whitespaces could be removed when using get_field(), but this concerns SQL not PHP. I’m also aware that SQL functions could be used to trim the whitespaces, however, keeping the source data clean is better option in this case.

    Any help appreciated as always!

    Paul S.

  • You would have to trim the values before inserting into DB.

    https://www.php.net/manual/en/function.trim.php

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.