jackk Posted August 6, 2022 Posted August 6, 2022 Hi Just trying to figure out how to insert a variable in PHP (from the user configuration). I'm pretty new to PHP. Any help would be appreciated <?php $gross = $argv[1]; $pct = {var:pct} $total = $gross * $pct + $gross; $sum = round($total, 2); $sum2 = number_format($total, 2); $tax = number_format($gross * $pct, 2); $item = array('title' => "Total = $$sum2, Tax = $$tax", 'subtitle' => "↵ to copy to clipboard", 'arg' => "$sum"); $json = json_encode(array('items' => array($item))); echo $json; // send JSON to Alfred ?>
vitor Posted August 6, 2022 Posted August 6, 2022 See handling workflow/environment variables. Variables from the User Configuration are environment variables. So in your case: $pct = getenv('pct')
jackk Posted August 6, 2022 Author Posted August 6, 2022 Thank you but that didn't work. Could you take a look at my workflow. Thanks
vitor Posted August 6, 2022 Posted August 6, 2022 You’re missing the semi-colon at the end on the $pct line. When something doesn’t work, the first step is to take a look at the Workflow Debugger.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now