Skip to content

Instantly share code, notes, and snippets.

@duswie
Created June 24, 2021 15:34
Show Gist options
  • Save duswie/002de4cec761fa82d369830586d393ae to your computer and use it in GitHub Desktop.
Save duswie/002de4cec761fa82d369830586d393ae to your computer and use it in GitHub Desktop.
PHP array to commandline parameter string
<?php
$params = [
'par1' => 'value1',
'par2' => 'value2',
'flag' => null,
];
$params_string = array_reduce( array_keys($params), fn($carry, $item) => $params[$item] ? $carry.'--'.$item.'='.$params[$item].' ' : $carry.'--'.$item.' ', '');
//OUTPUT: "--par1=value1 --par2=value2 --flag "
@PowerPlus123
Copy link

Hello Dustin,
we are the leading provider of smart meter gateways and communication technology in germany and we enable secure data transmission in the smart grid. We'd like to talk to you about some of your work concerning the smgw.
Please feel free to contact us at info@ppc-ag.de
We'd love to hear from you.

Best regards
Power Plus Communications AG
This is our website: https://www.ppc-ag.de/en/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment