function

  • The quickest method for determining if your PHP array is empty

    The quickest method for determining if your PHP array is empty

    The fastest way to check if an array is empty To check whether a PHP array is empty or not, use the empty() function: This is how I prefer to do it. However, there are several ways to determine whether an array is empty, like: You can choose to end the process there or continue reading to…

  • Easily convert a PHP array to JSON

    Easily convert a PHP array to JSON

    Convert a PHP array to JSON To convert a PHP array to JSON, you can use the json_encode() function. Here’s how it’s done: This code piece, when run, will produce the following output: {“foo”:”bar”,”baz”:”qux”}. Your PHP array is now a JSON string in an instant! Let’s unwrap the mystique around json_encode(): When to convert a PHP…