to-bool

The to-bool operation converts the input value into a boolean (true or false). This is useful when you need a clear yes/no flag for conditions, routing, or API calls.

How it works

The following values are treated as false:

  • false (already boolean false)
  • 0 (integer zero)
  • 0.0 (float zero)
  • “” (empty string)
  • “0” (string containing zero)
  • [] (empty array)
  • null

All other values are treated as true, including:

  • Any non-zero number (positive or negative)
  • Any non-empty string (even “false” or “0.0”)
  • Any non-empty array
  • Any object or resource

Examples

InputResult
falsefalse
truetrue
0false
-1true
0.0false
“0”false
“false”true
“hello”true
[]false
[0]true
nullfalse

Usage in PalDock

Use to-bool when you need to:

  • Normalize form inputs (e.g., interpret checkbox-like fields as true/false).
  • Guarantee a boolean value before a Condition or Router element.
  • Send proper boolean values in API requests (true/false instead of text or numbers).

Best Practices

  • Remember that the string “0” is the only non-empty string treated as false.
  • The string “false” is considered true (because it is non-empty). If you need to handle “true”/”false” text literally, normalize the string first.
  • Empty arrays are false; arrays with at least one item are true.

References

https://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.castinghttps://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting

Insights that
helps you grow

  • Platform Pick 12: Rollout
    As you approach the official rollout of your affiliate platform, it’s time to take a step back and make sure everything is in place. A…
  • Platform Pick 11: Integrate and Test it
    When it comes to affiliate marketing, tracking clicks and leads is key to making sure you’re paying affiliates correctly and measuring success. But it’s not…
  • Platform Pick 10: Business, Legal, and IT Prep
    Now that you’ve narrowed down your platform choice, it’s time to make sure everything checks out from a business, legal, and technical perspective. This step…