WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

acf_str_replace() ACF 5.3.8

This function will replace an array of strings much like str_replace The difference is the extra logic to avoid replacing a string that has alread been replaced This is very useful for replacing date characters as they overlap with eachother

Хуков нет.


$post_id. (int)


acf_str_replace( $string, $search_replace );
$string **
По умолчанию: ''
$search_replace **
По умолчанию: array()

Список изменений

С версии 5.3.8 Введена.

Код acf_str_replace() ACF 5.9.1

function acf_str_replace( $string = '', $search_replace = array() ) {
	// vars
	$ignore = array();
	// remove potential empty search to avoid PHP error
	// loop over conversions
	foreach( $search_replace as $search => $replace ) {
		// ignore this search, it was a previous replace
		if( in_array($search, $ignore) ) continue;
		// bail early if subsctring not found
		if( strpos($string, $search) === false ) continue;
		// replace
		$string = str_replace($search, $replace, $string);
		// append to ignore
		$ignore[] = $replace;
	// return
	return $string;