acf_encode_choices()
acf_encode_choices
description
Хуков нет.
Возвращает
$post_id
. (int)
Использование
acf_encode_choices( $array, $show_keys );
- $array **
- -
По умолчанию: array() - $show_keys **
- -
По умолчанию: true
Список изменений
С версии 5.0.0 | Введена. |
Код acf_encode_choices() acf encode choices ACF 6.0.4
function acf_encode_choices( $array = array(), $show_keys = true ) { // bail early if not array (maybe a single string) if ( ! is_array( $array ) ) { return $array; } // bail early if empty array if ( empty( $array ) ) { return ''; } // vars $string = ''; // if allowed to show keys (good for choices, not for default values) if ( $show_keys ) { // loop foreach ( $array as $k => $v ) { // ignore if key and value are the same if ( strval( $k ) == strval( $v ) ) { continue; } // show key in the value $array[ $k ] = $k . ' : ' . $v; } } // implode $string = implode( "\n", $array ); // return return $string; }