WP_CLI\Utils
assoc_args_to_str()
Composes associative arguments into a command string.
No Hooks.
Returns
String.
Usage
assoc_args_to_str( $assoc_args );
- $assoc_args(required)
- .
assoc_args_to_str() assoc args to str code WP-CLI 2.13.0-alpha
function assoc_args_to_str( $assoc_args ) {
$str = '';
foreach ( $assoc_args as $key => $value ) {
if ( true === $value ) {
$str .= " --$key";
} elseif ( is_array( $value ) ) {
foreach ( $value as $v ) {
$str .= assoc_args_to_str(
[
$key => $v,
]
);
}
} else {
$str .= " --$key=" . escapeshellarg( $value );
}
}
return $str;
}