hebrevc()
The hebrevc() function is used to convert Hebrew text to visual text for display on a web page, with support for right-to-left text. The syntax of the hebrevc()
⚠️ Removed in PHP 8.0.0: The hebrevc() function was removed in PHP 8.0.0. The examples below will cause a fatal error on modern PHP versions. For modern web development, use CSS direction: rtl to handle right-to-left text layout. The legacy syntax is documented below for reference:
The hebrevc() function was used to convert logical Hebrew text (stored in reading order) to visual text (laid out the way it should appear on screen). It behaved like hebrev(), but additionally converted newlines (\n) into HTML line breaks (<br>\n), which made it convenient for printing multi-line Hebrew directly into a web page.
Syntax
string hebrevc ( string $hebrew_text [, int $max_chars_per_line = 0 ] )Parameters
| Parameter | Required | Description |
|---|---|---|
$hebrew_text | Yes | The logical-order Hebrew string to convert to visual order. |
$max_chars_per_line | No | Maximum number of characters per line. 0 (the default) means no maximum (lines are not broken on a character count). |
Return value
Returns a string containing the converted visual text, with newlines turned into <br>\n.
Basic example
<?php
$hebrew_text = "כן, אני מדבר עברית";
echo hebrevc($hebrew_text);
?>In this example, we have a string variable $hebrew_text containing some Hebrew text. We use the hebrevc() function to convert the Hebrew text to visual text for display on a web page.
As you can see, the hebrevc() function has converted the Hebrew text to visual text and displayed it in the correct order and format.
The hebrevc() function can also limit the number of characters per line in the output. Here is an example with a limit of 40 characters per line:
Limiting characters per line
<?php
$hebrew_text = "כן, אני מדבר עברית";
echo hebrevc($hebrew_text, 40);
?>In this example, we have a string variable $hebrew_text containing some Hebrew text, and we use the hebrevc() function with a limit of 40 characters per line.
As you can see, the hebrevc() function has limited the number of characters per line to 40.
Note that hebrevc() is a legacy function. For modern projects, rely on CSS direction: rtl and proper Unicode handling to ensure correct display and accessibility for Hebrew readers.
Related functions
hebrev()— converts logical Hebrew to visual order without turning newlines into<br>.nl2br()— inserts HTML line breaks before newlines in a string (the still-supported way to handle the<br>part).- PHP String functions — overview of the string-handling functions in PHP.