What are some potential pitfalls of using wordwrap in PHP for formatting navigation menus?

One potential pitfall of using wordwrap in PHP for formatting navigation menus is that it may break up words inappropriately, leading to awkward line breaks. To solve this, you can use the PHP function `mb_strimwidth` instead, which will truncate the string at a specified length without breaking words.

<?php
$menu_item = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
$max_length = 20;

if (mb_strlen($menu_item) > $max_length) {
    $menu_item = mb_strimwidth($menu_item, 0, $max_length, '...');
}

echo $menu_item;
?>