WP_CLI\Utils
assoc_args_to_str()
Composes associative arguments into a command string.
No Hooks.
Return
String
.
Usage
assoc_args_to_str( $assoc_args );
- $assoc_args(array) (required)
- Associative arguments to compose.
assoc_args_to_str() assoc args to str code WP-CLI 2.8.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; }