试试这个php内置函数array_walk_recursive
function wpse_do_something_on_data() {
$data = array(
\'repeater-1\' => array(
array(
\'user_defined_field1\' => \'http://www.domain-001.com\',
\'user_defined_field2\' => \'http://www.domain-002.com\',
),
array(
\'user_defined_field1\' => \'http://www.domain-011.com\',
\'user_defined_field2\' => \'http://www.domain-012.com\',
),
),
\'repeater-2\' => array(
array(
\'user_defined_field1\' => \'http://www.domain-101.com\',
\'user_defined_field2\' => \'http://www.domain-102.com\',
),
array(
\'user_defined_field1\' => \'http://www.domain-111.com\',
\'user_defined_field2\' => \'http://www.domain-112.com\',
),
),
);
array_walk_recursive( $data, \'wpse_callback\' );
return $data;
}
function wpse_callback( &$value, $key ) {
$value = str_replace( \'http://\', \'keyword\', $value );
}
$my_data = wpse_do_something_on_data();
var_dump( $my_data );