• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Cut an arabic string

php


PHP Snippet 1:

mb_internal_encoding('UTF-8');

PHP Snippet 2:

return '...'.mb_substr($str, 0, $limit - 3, "UTF-8"); // UTF-8 is optional

PHP Snippet 3:

 public static function shorten_arabic_text($text, $lenght)
        {
            mb_internal_encoding('UTF-8');
            $out = mb_strlen($text) > $lenght ? mb_substr($text, 0, $lenght) . " ..." : $text;
            return $out;
        }

Related Snippets

Laravel SQL query midnight time not showing

Problem with fetching data from database in Laravel

How to pass security cloudflare server with php curl

Alert message after submitting form in PHP

php 7 php.ini upload_max_filesize not working

PHP function Not Working As Expected From functions.php Include File

(Cache::lock()) -> get() -- Under what conditions does it return false?

WordPress Subquery returns more than 1 row on SELECT

How to submit the custom form data in database in WordPress without plugin using ajax?

PHP date() with timezone?

Can't exclude directories from .htaccess mobile redirect?

The sum of the user's points

How to remove Deprecated SymfonyComponentDebugDebugClassLoader?

Can't remotely connect to MySQL error (13) with PHP script, connecting through CLI works

Facebook PHP SDK - will not logout properly

About Contact Privacy policy Terms and conditions