PO::prepend_each_line
Inserts $with in the beginning of every new line of $input_string and returns the modified string
Метод класса: PO{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$result = PO::prepend_each_line( $input_string, $with );
- $input_string(строка) (обязательный)
- prepend lines in this string.
- $with(строка) (обязательный)
- prepend lines with this string.
Код PO::prepend_each_line() PO::prepend each line WP 7.1.4
public static function prepend_each_line( $input_string, $with ) {
$lines = explode( "\n", $input_string );
$append = '';
if ( "\n" === substr( $input_string, -1 ) && '' === end( $lines ) ) {
/*
* Last line might be empty because $input_string was terminated
* with a newline, remove it from the $lines array,
* we'll restore state by re-terminating the string at the end.
*/
array_pop( $lines );
$append = "\n";
}
foreach ( $lines as &$line ) {
$line = $with . $line;
}
unset( $line );
return implode( "\n", $lines ) . $append;
}