backslashit( string $value ): string

In this article

Adds backslashes before letters and before a number at the start of a string.

Parameters

$valuestringrequired
Value to which backslashes will be added.

Return

string String with backslashes inserted.

Source

function backslashit( $value ) {
	if ( isset( $value[0] ) && $value[0] >= '0' && $value[0] <= '9' ) {
		$value = '\\\\' . $value;
	}
	return addcslashes( $value, 'A..Za..z' );
}

Changelog

VersionDescription
0.71Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.