PHP String hebrevc() Function
The PHP String hebrevc() function is used to convert logical Hebrew text to visual text with newline conversion. This function is identical to hebrev(), but it converts newlines (\n) to "<br>\n". It attempts to avoid breaking words.
Syntax
Below is the syntax of the PHP String hebrevc() function −
string hebrevc ( string $hebrew_text [, int $max_chars_per_line = 0 ] )
Parameters
Below are the parameters of the hebrevc() function −
$hebrew_text − It contains the information about a hebrew string input.
$max_chars_per_line − It contains the information about max number of characters per line that will be returned.
Return Value
The hebrevc() function returns the visual string.
PHP Version
This function is deprecated as of PHP 7.4.0 and removed as of PHP 8.0.0. Relying on this function is strongly discouraged.
Example 1
First we will show you the basic example of the PHP String hebrevc() function to convert logical hebrew to visual text.
<?php
echo hebrevc(" \n ");
?>
Output
Here is the outcome of the following code −
Example 2
Here is another program to show the usage of the hebrevc() function.
<?php // Hebrew text in right-to-left flow $hebrew_text = " \n "; $max_chars = 10; // Maximum characters per line // Convert Hebrew text and control line breaks $converted_text = hebrevc($hebrew_text, $max_chars); echo $converted_text; ?>
Output
This will generate the below output −
Example 3
This program accepts Hebrew text from the user using an HTML form, converts it using hebrevc(), and displays the results.
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$hebrew_text = $_POST['hebrew_text'];
$converted_text = hebrevc($hebrew_text);
}
?>
<form method="post">
<label for="hebrew_text">Enter Hebrew Text:</label><br>
<textarea name="hebrew_text" rows="4" cols="50"></textarea><br><br>
<input type="submit" value="Convert">
</form>
Output
This will create the below output −