本文整理汇总了PHP中acf_str_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP acf_str_exists函数的具体用法?PHP acf_str_exists怎么用?PHP acf_str_exists使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了acf_str_exists函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: acf_decode_choices
function acf_decode_choices($string = '')
{
// validate
if (is_numeric($string)) {
// force array on single numeric values
return array($string);
} elseif (!is_string($string)) {
// bail early if not a a string
return $string;
}
// vars
$array = array();
// explode
$lines = explode("\n", $string);
// key => value
foreach ($lines as $line) {
// vars
$k = trim($line);
$v = trim($line);
// look for ' : '
if (acf_str_exists(' : ', $line)) {
$line = explode(' : ', $line);
$k = trim($line[0]);
$v = trim($line[1]);
}
// append
$array[$k] = $v;
}
// return
return $array;
}
示例2: update_value
function update_value($value, $post_id, $field)
{
// no formatting needed for empty value
if (empty($value)) {
return $value;
}
// remove ','
if (acf_str_exists(',', $value)) {
$value = str_replace(',', '', $value);
}
// return
return $value;
}
示例3: acf_decode_choices
function acf_decode_choices($string = '')
{
// bail early if already array
if (is_array($string)) {
return $string;
}
// vars
$array = array();
// bail ealry if not string
if (!is_string($string)) {
return $array;
}
// explode choices from each line
if (!empty($string)) {
// stripslashes ("")
$string = stripslashes_deep($string);
// explode
$temp = explode("\n", $string);
// key => value
foreach ($temp as $v) {
if (acf_str_exists(' : ', $v)) {
$v = explode(' : ', $v);
$array[trim($v[0])] = trim($v[1]);
} else {
$array[trim($v)] = trim($v);
}
}
}
// return
return $array;
}
示例4: acf_decode_choices
function acf_decode_choices($string = '', $array_keys = false)
{
// bail early if already array
if (is_array($string)) {
return $string;
// allow numeric values (same as string)
} elseif (is_numeric($string)) {
// do nothing
// bail early if not a string
} elseif (!is_string($string)) {
return array();
// bail early if is empty string
} elseif ($string === '') {
return array();
}
// vars
$array = array();
// explode
$lines = explode("\n", $string);
// key => value
foreach ($lines as $line) {
// vars
$k = trim($line);
$v = trim($line);
// look for ' : '
if (acf_str_exists(' : ', $line)) {
$line = explode(' : ', $line);
$k = trim($line[0]);
$v = trim($line[1]);
}
// append
$array[$k] = $v;
}
// return only array keys? (good for checkbox default_value)
if ($array_keys) {
return array_keys($array);
}
// return
return $array;
}
示例5: acf_decode_choices
function acf_decode_choices($string = '')
{
// bail early if nota a string
if (!is_string($string)) {
return $string;
}
// vars
$array = array();
// explode choices from each line
//if( !empty($string) ) {
// stripslashes ("")
//$string = stripslashes_deep($string);
// explode
$lines = explode("\n", $string);
// key => value
foreach ($lines as $line) {
// vars
$k = trim($line);
$v = trim($line);
// look for ' : '
if (acf_str_exists(' : ', $line)) {
$line = explode(' : ', $line);
$k = trim($line[0]);
$v = trim($line[1]);
}
// append
$array[$k] = $v;
}
//}
// bail early if no choices
if (empty($array)) {
return '';
}
// return
return $array;
}