הרשם שאלות ותשובות רשימת חברים לוח שנה הודעות מהיום

חזור   הוסטס - פורום אחסון האתרים הגדול בישראל > עיצוב גראפי, תכנות על כל שפותיו וקידום ושיווק אתרים > פורום תיכנות

   
|!|

 
 
כלים לאשכול תצורת הצגה
Prev הודעה קודמת   הודעה הבאה Next
ישן 28-05-09, 19:08   # 10
vadimg88
חבר מתקדם
 
מיני פרופיל
תאריך הצטרפות: Feb 2008
גיל: 37
הודעות: 710

vadimg88 לא מחובר  

הנה זה יתמוך ב multibyte וגם הורדתי את ה preg_match והחלפתי בפקודת IF פשוטה.

PHP קוד:
<?php

/**
 * Count number of chars in a string 
 * Supports multi byte chars
 *
 * @param string $string
 */
function countChars$string$encoding='UTF-8' )
{
    return 
mb_strlen($string$encoding);
}

/**
 * Check if the given int is between two values
 *
 * @param int $value
 * @param int $firstElement
 * @param int $secondElement
 * @return bool
 */
function valueInBetween$value$firstElement$secondElement )
{
    return ( (int) 
$value $firstElement && (int) $value $secondElement ) ? TRUE FALSE;
}

# Count english
$string "asfcas";
echo 
countChars($string);

# Count hebrew multi byte
$string "דגעגכדעיגד";
echo 
countChars($string);

# Check if it's bettwen two values, English
$string "asfcas";
var_dump(valueInBetween(countChars($string), 4111)); // true

# Check if it's bettwen two values, Hebrew
$string "שגדעגיעק";
var_dump(valueInBetween(countChars($string), 4111)); // true

$string "שגדעגיעק";
var_dump(valueInBetween(countChars($string), 12111)); // false
  Reply With Quote
 

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 


חוקי פירסום
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


כל הזמנים הם GMT +2. הזמן כעת הוא 06:47.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ