Created
June 24, 2021 15:34
-
-
Save duswie/002de4cec761fa82d369830586d393ae to your computer and use it in GitHub Desktop.
PHP array to commandline parameter string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/