hi,
i find this custom_truncate,for cut text on right side,but not understand how cut in right side,beacause also custom_truncate cut always on left side
To add a custom truncate option to the [frm-field-value] shortcode, follow the example below.
Usage example: [frm-field-value field_id=x custom_truncate=1]
add_filter( 'do_shortcode_tag', 'truncate_frm_field_value', 10, 3 );
function truncate_frm_field_value( $output, $tag, $attr ) {
if ( 'frm-field-value' === $tag && isset( $attr['custom_truncate'] ) && is_numeric( $attr['custom_truncate'] ) ) {
$output = FrmAppHelper::truncate( $output, $attr['custom_truncate'] );
}
return $output;
}
truncate always reduces the length of a string from the right. This is how PHP works. If you want to get a portion of a string or remove characters from the left side, use substr.
Tks, but i dont know where to put substr string
Please login or Register to submit your answer