Ar-PHP

Arabic

----------------------------------------------------------------------

Copyright (c) 2006-2023 Khaled Al-Sham'aa.

http://www.ar-php.org

PHP Version >= 5.6


LICENSE

This program is open source product; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/lgpl.txt.


Class Name: PHP and Arabic Language

Filename: ar-php.php

Original Author(s): Khaled Al-Sham'aa khaled@ar-php.org

Purpose: Set of PHP classes developed to enhance Arabic web applications by providing set of tools includes stem-based searching, translitiration, soundex, Hijri calendar, charset detection and converter, spell numbers, keyboard language, Muslim prayer time, auto-summarization, and more...


Tags
desc

Set of PHP classes developed to enhance Arabic web applications by providing set of tools includes translitiration, soundex, Hijri calendar, spell numbers, keyboard language, and more...

author

Khaled Al-Shamaa khaled@ar-php.org

copyright

2006-2023 Khaled Al-Shamaa

license

LGPL http://www.gnu.org/licenses/lgpl.txt

version
6.3.4

released in Apr 5, 2023

link
http://www.ar-php.org

Table of Contents

$version  : string
__construct()  : mixed
addGlyphs()  : void
Add extra glyphs
ar2en()  : string
Transliterate Arabic string into English by render them in the orthography of the English language
arIdentify()  : array<string|int, int>
Identify Arabic text in a given UTF-8 multi language string
arNormalizeText()  : string
Normalizes the input provided and returns the normalized string.
arPlural()  : string
Get proper Arabic plural form There are 4 plural forms in Arabic language: - Form for 2 - Form for numbers that end with a number between 3 and 10 (like: 103, 1405, 23409) - Form for numbers that end with a number between 11 and 99 (like: 1099, 278) - Form for numbers above 100 ending with 0, 1 or 2 (like: 100, 232, 3001)
arQueryAllForms()  : string
Get most possible Arabic lexical forms of user search keywords
arQueryOrderBy()  : string
Get more relevant order by section related to the user search keywords
arQueryWhereCondition()  : string
Build WHERE section of the SQL statement using defind lex's rules, search mode [AND | OR], and handle also phrases (inclosed by "") using normal LIKE condition to match it as it is.
arSentiment()  : array<string|int, bool|float>
Arabic Sentiment Analysis
arSummary()  : string
Core summarize function that implement required steps in the algorithm
arSummaryKeywords()  : string
Extract keywords from a given Arabic string (document content)
arSummaryLoadExtra()  : void
Load enhanced Arabic stop words list
date()  : string
Format a local time/date in Arabic string
dateCorrection()  : int
Calculate Hijri calendar correction using Um-Al-Qura calendar information
dd2dms()  : string
Convert coordinates presented in float number in degree unit scale (e.g. -12.5822 value) into degrees, minutes and seconds (e.g. -12°34'56" formula)
dd2olc()  : string
Encode a location coordinates (latitude and longitude in WGS84) into Open Location Code Ref: https://github.com/google/open-location-code/blob/master/docs/specification.md
diffForHumans()  : string
Get the difference in a human readable format.
dms2dd()  : float
Convert coordinates presented in degrees, minutes and seconds (e.g. 12°34'56"S formula) into usual float number in degree unit scale (e.g. -12.5822 value)
en2ar()  : string
Transliterate English string into Arabic by render them in the orthography of the Arabic language
fixKeyboardLang()  : string
This method will automatically detect the language of content supplied in the input string. It will return the suggestion of correct inserted text.
getDateMode()  : int
Getting $mode value that refer to output mode format 1) Hijri format (Islamic calendar) 2) Arabic month names used in Middle East countries 3) Arabic Transliteration of Gregorian month names 4) Both of 2 and 3 formats together 5) Libyan way 6) Algeria and Tunis style 7) Morocco style 8) Hijri format (Islamic calendar) in English
getNorm()  : bool
Get given normalization form status.
getNumberFeminine()  : int
Get the feminine flag of counted object
getNumberFormat()  : int
Get the grammer position flag of counted object
getNumberOrder()  : int
Get the ordering flag value
getPrayTime()  : array<string|int, string>
Calculate Salat times for the date set in setSalatDate methode, and location set in setSalatLocation.
getQibla()  : float
Determine Qibla direction using basic spherical trigonometric formula
getQueryArrFields()  : array<string|int, string>
Getting values of $_fields Array in array format
getQueryMode()  : int
Getting $mode propority value that refer to search mode [0 for OR logic | 1 for AND logic]
getQueryStrFields()  : string
Getting values of $_fields array in String format (comma delimated)
getSoundexCode()  : string
Get the soundex key calculation method used now
getSoundexLang()  : string
Get the soundex key language used now
getSoundexLen()  : int
Get the soundex key length used now
hijriMonthDays()  : int
Calculate how many days in a given Hijri month
int2indic()  : string
Represent integer number in Arabic-Indic digits using HTML entities
int2str()  : string
Spell integer number in Arabic idiom
int2strItem()  : string
Spell integer number in Arabic idiom followed by plural form of the counted item
isArabic()  : bool
Find out if given string is Arabic text or not
isFemale()  : bool
Arabic Gender Guesser
mktime()  : int
This will return current Unix timestamp for given Hijri date (Islamic calendar)
mktimeCorrection()  : int
Calculate Hijri calendar correction using Um-Al-Qura calendar information
money2str()  : string
Spell number in Arabic idiom as money
noDots()  : string
Strip Dots and Hamzat
olc2dd()  : array<string|int, null|float>
Decode an Open Location Code string into its location coordinates in decimal degrees.
setDateMode()  : object
Setting value for $_arDateMode scalar
setNorm()  : object
Set given normalization form status.
setNumberFeminine()  : object
Set feminine flag of the counted object
setNumberFormat()  : object
Set the grammar position flag of the counted object
setNumberOrder()  : object
Set the ordering flag, is it normal number or ordering number
setQueryArrFields()  : object
Setting value for $_fields array
setQueryMode()  : object
Setting $mode propority value that refer to search mode [0 for OR logic | 1 for AND logic]
setQueryStrFields()  : object
Setting value for $_fields array
setSalatConf()  : object
Setting rest of Salat calculation configuration
setSalatDate()  : object
Setting date of day for Salat calculation
setSalatLocation()  : object
Setting location information for Salat calculation
setSoundexCode()  : object
Set the mapping code of the soundex key (default value is "soundex")
setSoundexLang()  : object
Set the language of the soundex key (default value is "en")
setSoundexLen()  : object
Set the length of soundex key (default value is 4)
soundex()  : string
Arabic soundex algorithm takes Arabic word as an input and produces a character string which identifies a set words that are (roughly) phonetically alike.
standard()  : string
This function will standardize Arabic text to follow writing standards (just like magazine/newspapers rules), for example spaces before and after punctuations, brackets and units etc .
str2int()  : int
Convert Arabic idiom number string into Integer
stripHarakat()  : string
Strip Harakat
strtotime()  : int
Arabic arStrToTime Function
swapAe()  : string
Make conversion to swap that odd Arabic text by original English sentence you meant when you type on your keyboard (if keyboard language was incorrect)
swapAf()  : string
Make conversion to swap that odd Arabic text by original French sentence you meant when you type on your keyboard (if keyboard language was incorrect)
swapEa()  : string
Make conversion to swap that odd English text by original Arabic sentence you meant when you type on your keyboard (if keyboard language was incorrect)
swapFa()  : string
Make conversion to swap that odd French text by original Arabic sentence you meant when you type on your keyboard (if keyboard language was incorrect)
utf8Glyphs()  : string
Convert Arabic string into glyph joining in UTF-8 hexadecimals stream (take care of whole the document including English sections as well as numbers and arcs etc...)
volc()  : bool
Determine if an Open Location Code is valid.

Properties

$version

public string $version = '6.3.4'

Methods

__construct()

public __construct() : mixed
Return values
mixed

addGlyphs()

Add extra glyphs

public addGlyphs(string $char, string $hex[, bool $prevLink = true ][, bool $nextLink = true ]) : void
Parameters
$char : string

Char to be added

$hex : string

String of 16 hexadecimals digits refers to the letter unicode in the following order ISOLATED FORM, FINAL FORM, INITIAL FORM, MEDIAL FORM (e.g. for Arabic letter HEH 'FEE9FEEAFEEBFEEC')

$prevLink : bool = true

If TRUE (default), when this letter be previous, then next will be linked to it

$nextLink : bool = true

If TRUE (default), when this letter be next, then previous will be linked to it

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
void

ar2en()

Transliterate Arabic string into English by render them in the orthography of the English language

public ar2en(string $string[, string $standard = 'UNGEGN' ]) : string
Parameters
$string : string

Arabic string you want to transliterate

$standard : string = 'UNGEGN'

Transliteration standard, default is UNGEGN and possible values are [UNGEGN, UNGEGN+, RJGC, SES, ISO233]

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Out of vocabulary Arabic string in English characters

arIdentify()

Identify Arabic text in a given UTF-8 multi language string

public arIdentify(string $str[, bool $html = true ]) : array<string|int, int>
Parameters
$str : string

UTF-8 multi language string

$html : bool = true

If True, then ignore the HTML tags (default is TRUE)

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
array<string|int, int>

Offset of the beginning and end of each Arabic segment in sequence in the given UTF-8 multi language string

arNormalizeText()

Normalizes the input provided and returns the normalized string.

public arNormalizeText(string $text[, string $numeral = null ]) : string
Parameters
$text : string

The input string to normalize.

$numeral : string = null

Symbols used to represent numerical digits [Arabic, Hindu, or Persian] default is null (i.e., will not normalize digits in the given string).

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

The normalized string.

arPlural()

Get proper Arabic plural form There are 4 plural forms in Arabic language: - Form for 2 - Form for numbers that end with a number between 3 and 10 (like: 103, 1405, 23409) - Form for numbers that end with a number between 11 and 99 (like: 1099, 278) - Form for numbers above 100 ending with 0, 1 or 2 (like: 100, 232, 3001)

public arPlural(string $singular, int $count[, string $plural2 = null ][, string $plural3 = null ][, string $plural4 = null ]) : string
Parameters
$singular : string

Singular word (e.g., عنصر).

$count : int

The number (e.g. item count) to determine the proper plural form.

$plural2 : string = null

Plural form 2 (e.g., عنصران). If NULL [default] retrive from internal JSON dataset.

$plural3 : string = null

Plural form 3 (e.g., عناصر). If NULL [default] retrive from internal JSON dataset.

$plural4 : string = null

Plural form 4 (e.g., عنصرا). If NULL [default] retrive from internal JSON dataset.

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Proper plural form of the given singular form

arQueryAllForms()

Get most possible Arabic lexical forms of user search keywords

public arQueryAllForms(string $arg) : string
Parameters
$arg : string

String that user search for

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

list of most possible Arabic lexical forms for given keywords

arQueryOrderBy()

Get more relevant order by section related to the user search keywords

public arQueryOrderBy(string $arg) : string
Parameters
$arg : string

String that user search for in the database table

Tags
author

Saleh AlMatrafe saleh@saleh.cc

author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

sub SQL ORDER BY section

arQueryWhereCondition()

Build WHERE section of the SQL statement using defind lex's rules, search mode [AND | OR], and handle also phrases (inclosed by "") using normal LIKE condition to match it as it is.

public arQueryWhereCondition(string $arg) : string
Parameters
$arg : string

String that user search for in the database table

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

The WHERE section in SQL statement (MySQL database engine format)

arSentiment()

Arabic Sentiment Analysis

public arSentiment(string $text) : array<string|int, bool|float>
Parameters
$text : string

Arabic review string

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
array<string|int, bool|float>

of 2 elements: boolean isPositive (negative if false), and float probability (range from 0 to 1)

arSummary()

Core summarize function that implement required steps in the algorithm

public arSummary(string $str, string $keywords, int $int, int $mode, int $output) : string
Parameters
$str : string

Input Arabic document as a string

$keywords : string

List of keywords higlited by search process

$int : int

Sentences value (see $mode effect also)

$mode : int

Mode of sentences count [1|2] for "number" and "rate" modes respectively

$output : int

Output mode [1|2] for "summary" and "highlight" modes respectively

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Output summary requested

arSummaryKeywords()

Extract keywords from a given Arabic string (document content)

public arSummaryKeywords(string $str, int $int) : string
Parameters
$str : string

Input Arabic document as a string

$int : int

Number of keywords required to be extracting from input string (document content)

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

List of the keywords extracting from input Arabic string (document content)

arSummaryLoadExtra()

Load enhanced Arabic stop words list

public arSummaryLoadExtra() : void
Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
void

date()

Format a local time/date in Arabic string

public date(string $format, int $timestamp, int $correction) : string
Parameters
$format : string

Format string (same as PHP date function)

$timestamp : int

Unix timestamp

$correction : int

To apply correction factor (+/- 1-2) to standard hijri calendar

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Format Arabic date string according to given format string using the given integer timestamp or the current local time if no timestamp is given.

dateCorrection()

Calculate Hijri calendar correction using Um-Al-Qura calendar information

public dateCorrection(int $time) : int
Parameters
$time : int

Unix timestamp

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
int

Correction factor to fix Hijri calendar calculation using Um-Al-Qura calendar information

dd2dms()

Convert coordinates presented in float number in degree unit scale (e.g. -12.5822 value) into degrees, minutes and seconds (e.g. -12°34'56" formula)

public dd2dms(float $value) : string
Parameters
$value : float

Coordinate presented in float number in degree unit scale (e.g. -12.5822 value)

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Equivalent coordinate presented in degrees, minutes and seconds (e.g. -12°34'56" formula)

dd2olc()

Encode a location coordinates (latitude and longitude in WGS84) into Open Location Code Ref: https://github.com/google/open-location-code/blob/master/docs/specification.md

public dd2olc(float $latitude, float $longitude[, int $codeLength = 10 ]) : string
Parameters
$latitude : float

Coordinate presented in float number in degree unit scale (e.g. 34.67175)

$longitude : float

Coordinate presented in float number in degree unit scale (e.g. 36.263625)

$codeLength : int = 10

Code length, default value is 10 (this provides an area that is 1/8000 x 1/8000 degree in size, roughly 14x14 meters)

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Open Location Code string (e.g. 8G6RM7C7+PF)

diffForHumans()

Get the difference in a human readable format.

public diffForHumans(int $time[, int|null $others = null ][, int $parts = 2 ][, bool $floor = true ]) : string
Parameters
$time : int

the timestamp that is being compared.

$others : int|null = null

if null passed, now will be used as comparison reference; if integer value, it will be used as reference timestamp. (default value is null).

$parts : int = 2

maximum number of parts to display (default value is 2).

$floor : bool = true

logic for rounding last part, if true then use floor, else use ceiling.

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

the difference in a human readable format.

dms2dd()

Convert coordinates presented in degrees, minutes and seconds (e.g. 12°34'56"S formula) into usual float number in degree unit scale (e.g. -12.5822 value)

public dms2dd(string $value) : float
Parameters
$value : string

Coordinate presented in degrees, minutes and seconds (e.g. 12°34'56"S formula)

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
float

Equivalent float number in degree unit scale (e.g. -12.5822 value)

en2ar()

Transliterate English string into Arabic by render them in the orthography of the Arabic language

public en2ar(string $string[, string $locale = 'en_US' ]) : string
Parameters
$string : string

English string you want to transliterate

$locale : string = 'en_US'

Locale information (e.g. 'en_GB' or 'de_DE')

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Out of vocabulary English string in Arabic characters

fixKeyboardLang()

This method will automatically detect the language of content supplied in the input string. It will return the suggestion of correct inserted text.

public fixKeyboardLang(string $str) : string

The accuracy of the automatic language detection increases with the amount of text entered.

Parameters
$str : string

Inserted string from the keyboard

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Fixed string language and letter case to the better guess

getDateMode()

Getting $mode value that refer to output mode format 1) Hijri format (Islamic calendar) 2) Arabic month names used in Middle East countries 3) Arabic Transliteration of Gregorian month names 4) Both of 2 and 3 formats together 5) Libyan way 6) Algeria and Tunis style 7) Morocco style 8) Hijri format (Islamic calendar) in English

public getDateMode() : int
Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
int

Value of $mode properity

getNorm()

Get given normalization form status.

public getNorm(string $form) : bool
Parameters
$form : string

One of the normalization forms ['stripTatweel', 'stripTanween', 'stripShadda', 'stripLastHarakat', 'stripWordHarakat', 'normaliseLamAlef', 'normaliseAlef', 'normaliseHamza', 'normaliseTaa']

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
bool

Selected normalization form status.

getNumberFeminine()

Get the feminine flag of counted object

public getNumberFeminine() : int
Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
int

return current setting of counted object feminine flag

getNumberFormat()

Get the grammer position flag of counted object

public getNumberFormat() : int
Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
int

return current setting of counted object grammer position flag

getNumberOrder()

Get the ordering flag value

public getNumberOrder() : int
Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
int

return current setting of ordering flag value

getPrayTime()

Calculate Salat times for the date set in setSalatDate methode, and location set in setSalatLocation.

public getPrayTime() : array<string|int, string>
Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

author

Hamid Zarrabi-Zadeh zarrabi@scs.carleton.ca

source
Return values
array<string|int, string>

of Salat times + sun rise in the following format hh:mm where hh is the hour in local format and 24 mode mm is minutes with leading zero to be 2 digits always array items is [$Fajr, $Sunrise, $Dhuhr, $Asr, $Maghrib, $Isha, $Sunset, $Midnight, $Imsak, array $timestamps]

getQibla()

Determine Qibla direction using basic spherical trigonometric formula

public getQibla() : float
Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

author

S. Kamal Abdali k.abdali@acm.org

source
Return values
float

Qibla Direction (from the north direction) in degrees

getQueryArrFields()

Getting values of $_fields Array in array format

public getQueryArrFields() : array<string|int, string>
Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
array<string|int, string>

Value of $_fields array in Array format

getQueryMode()

Getting $mode propority value that refer to search mode [0 for OR logic | 1 for AND logic]

public getQueryMode() : int
Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
int

Value of $mode properity

getQueryStrFields()

Getting values of $_fields array in String format (comma delimated)

public getQueryStrFields() : string
Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Values of $_fields array in String format (comma delimated)

getSoundexCode()

Get the soundex key calculation method used now

public getSoundexCode() : string
Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

return current setting for soundex key calculation method

getSoundexLang()

Get the soundex key language used now

public getSoundexLang() : string
Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

return current setting for soundex key language

getSoundexLen()

Get the soundex key length used now

public getSoundexLen() : int
Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
int

return current setting for soundex key length

hijriMonthDays()

Calculate how many days in a given Hijri month

public hijriMonthDays(int $m, int $y[, bool $umAlqoura = true ]) : int
Parameters
$m : int

Hijri month (Islamic calendar)

$y : int

Hijri year (Islamic calendar), valid range[1320-1459]

$umAlqoura : bool = true

Should we implement Um-Al-Qura calendar correction in this calculation (default value is true)

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
int

Days in a given Hijri month

int2indic()

Represent integer number in Arabic-Indic digits using HTML entities

public int2indic(int $number) : string
Parameters
$number : int

The number you want to present in Arabic-Indic digits using HTML entities

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

The Arabic-Indic digits represent inserted integer number using HTML entities

int2str()

Spell integer number in Arabic idiom

public int2str(int $number) : string
Parameters
$number : int

The number you want to spell in Arabic idiom

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

The Arabic idiom that spells inserted number

int2strItem()

Spell integer number in Arabic idiom followed by plural form of the counted item

public int2strItem(int $count, string $word) : string
Parameters
$count : int

The number you want to spell in Arabic idiom

$word : string

The counted item

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

The Arabic idiom that spells inserted number followed by plural form of the counted item.

isArabic()

Find out if given string is Arabic text or not

public isArabic(string $str) : bool
Parameters
$str : string

String

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
bool

True if given string is UTF-8 Arabic, else will return False

isFemale()

Arabic Gender Guesser

public isFemale(string $str) : bool

This function attempts to guess the gender of Arabic names.

Arabic nouns are either masculine or feminine. Usually when referring to a male, a masculine noun is usually used and when referring to a female, a feminine noun is used. In most cases the feminine noun is formed by adding a special characters to the end of the masculine noun. Its not just nouns referring to people that have gender. Inanimate objects (doors, houses, cars, etc.) is either masculine or feminine. Whether an inanimate noun is masculine or feminine is mostly arbitrary.

Parameters
$str : string

Arabic word you would like to check if it is feminine

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
bool

Return true if input Arabic word is feminine

mktime()

This will return current Unix timestamp for given Hijri date (Islamic calendar)

public mktime(int $hour, int $minute, int $second, int $hj_month, int $hj_day, int $hj_year, int $correction) : int
Parameters
$hour : int

Time hour

$minute : int

Time minute

$second : int

Time second

$hj_month : int

Hijri month (Islamic calendar)

$hj_day : int

Hijri day (Islamic calendar)

$hj_year : int

Hijri year (Islamic calendar)

$correction : int

To apply correction factor (+/- 1-2) to standard Hijri calendar

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
int

Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)

mktimeCorrection()

Calculate Hijri calendar correction using Um-Al-Qura calendar information

public mktimeCorrection(int $m, int $y) : int
Parameters
$m : int

Hijri month (Islamic calendar)

$y : int

Hijri year (Islamic calendar), valid range [1420-1459]

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
int

Correction factor to fix Hijri calendar calculation using Um-Al-Qura calendar information

money2str()

Spell number in Arabic idiom as money

public money2str(int $number[, string $iso = 'SYP' ][, string $lang = 'ar' ]) : string
Parameters
$number : int

The number you want to spell in Arabic idiom as money

$iso : string = 'SYP'

The three-letter Arabic country code defined in ISO 3166 standard

$lang : string = 'ar'

The two-letter language code in ISO 639-1 standard [ar|en]

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

The Arabic idiom that spells inserted number as money

noDots()

Strip Dots and Hamzat

public noDots(string $text) : string
Parameters
$text : string

Arabic text you would like to strip Dots and Hamzat from it.

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Arabic text written using letters without dots and Hamzat

olc2dd()

Decode an Open Location Code string into its location coordinates in decimal degrees.

public olc2dd(string $olc[, int $codeLength = 10 ]) : array<string|int, null|float>

Ref: https://github.com/google/open-location-code/blob/master/docs/specification.md

Parameters
$olc : string

Open Location Code string (e.g. 8G6RM7C7+PF)

$codeLength : int = 10

Code length, default value is 10 (this provides an area that is 1/8000 x 1/8000 degree in size, roughly 14x14 meters)

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
array<string|int, null|float>

Location coordinates in decimal degrees [latitude, longitude] in WGS84

setDateMode()

Setting value for $_arDateMode scalar

public setDateMode([int $mode = 1 ]) : object
Parameters
$mode : int = 1

Output mode of date function where:

  1. Hijri format (Islamic calendar)
  2. Arabic month names used in Middle East countries
  3. Arabic Transliteration of Gregorian month names
  4. Both of 2 and 3 formats together
  5. Libya style
  6. Algeria and Tunis style
  7. Morocco style
  8. Hijri format (Islamic calendar) in English
Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
object

$this to build a fluent interface

setNorm()

Set given normalization form status.

public setNorm(string $form, bool $status) : object
Parameters
$form : string

One of the normalization forms ['stripTatweel', 'stripTanween', 'stripShadda', 'stripLastHarakat', 'stripWordHarakat', 'normaliseLamAlef', 'normaliseAlef', 'normaliseHamza', 'normaliseTaa', 'all']

$status : bool

Normalization form status [true|false]

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
object

$this to build a fluent interface.

setNumberFeminine()

Set feminine flag of the counted object

public setNumberFeminine(int $value) : object
Parameters
$value : int

Counted object feminine (1 for masculine & 2 for feminine)

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
object

$this to build a fluent interface

setNumberFormat()

Set the grammar position flag of the counted object

public setNumberFormat(int $value) : object
Parameters
$value : int

Grammar position of counted object (1 if Marfoua & 2 if Mansoub or Majrour)

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
object

$this to build a fluent interface

setNumberOrder()

Set the ordering flag, is it normal number or ordering number

public setNumberOrder(int $value) : object
Parameters
$value : int

Is it an ordering number? default is 1 (use 1 if no and 2 if yes)

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
object

$this to build a fluent interface

setQueryArrFields()

Setting value for $_fields array

public setQueryArrFields(array<string|int, string> $arrConfig) : object
Parameters
$arrConfig : array<string|int, string>

Name of the fields that SQL statement will search them (in array format where items are those fields names)

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
object

$this to build a fluent interface

setQueryMode()

Setting $mode propority value that refer to search mode [0 for OR logic | 1 for AND logic]

public setQueryMode(int $mode) : object
Parameters
$mode : int

Setting value to be saved in the $mode propority [0 for OR logic | 1 for AND logic]

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
object

$this to build a fluent interface

setQueryStrFields()

Setting value for $_fields array

public setQueryStrFields(string $strConfig) : object
Parameters
$strConfig : string

Name of the fields that SQL statement will search them (in string format using comma as delimated)

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
object

$this to build a fluent interface

setSalatConf()

Setting rest of Salat calculation configuration

public setSalatConf([string $sch = 'Shafi' ][, float $sunriseArc = -0.833333 ][, float $ishaArc = -17.5 ][, float $fajrArc = -19.5 ][, string $view = 'Sunni' ]) : object

Convention [Fajr Angle, Isha Angle]

  • Muslim World League [-18, -17]
  • Islamic Society of North America (ISNA) [-15, -15]
  • Egyptian General Authority of Survey [-19.5, -17.5]
  • Umm al-Qura University, Makkah [-18.5, Isha 90 min after Maghrib, 120 min during Ramadan]
  • University of Islamic Sciences, Karachi [-18, -18]
  • Institute of Geophysics, University of Tehran [-17.7, -14*]
  • Shia Ithna Ashari, Leva Research Institute, Qum [-16, -14]

(*) Isha angle is not explicitly defined in Tehran method Fajr Angle = $fajrArc, Isha Angle = $ishaArc

Parameters
$sch : string = 'Shafi'

[Shafi|Hanafi] to define Muslims Salat calculation method (affect Asr time)

$sunriseArc : float = -0.833333

Sun rise arc (default value is -0.833333)

$ishaArc : float = -17.5

Isha arc (default value is -18)

$fajrArc : float = -19.5

Fajr arc (default value is -18)

$view : string = 'Sunni'

[Sunni|Shia] to define Muslims Salat calculation method (affect Maghrib and Midnight time)

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
object

$this to build a fluent interface

setSalatDate()

Setting date of day for Salat calculation

public setSalatDate([int $m = 8 ][, int $d = 2 ][, int $y = 1975 ]) : object
Parameters
$m : int = 8

Month of date you want to calculate Salat in

$d : int = 2

Day of date you want to calculate Salat in

$y : int = 1975

Year (four digits) of date you want to calculate Salat in

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
object

$this to build a fluent interface

setSalatLocation()

Setting location information for Salat calculation

public setSalatLocation([float $l1 = 36.20278 ][, float $l2 = 37.15861 ][, int $z = 2 ], int $e) : object
Parameters
$l1 : float = 36.20278

Latitude of location you want to calculate Salat time in

$l2 : float = 37.15861

Longitude of location you want to calculate Salat time in

$z : int = 2

Time Zone, offset from UTC (see also Greenwich Mean Time)

$e : int

Elevation, it is the observer's height in meters.

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
object

$this to build a fluent interface

setSoundexCode()

Set the mapping code of the soundex key (default value is "soundex")

public setSoundexCode(string $str) : object
Parameters
$str : string

Soundex key mapping code [soundex|phonix]

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
object

$this to build a fluent interface

setSoundexLang()

Set the language of the soundex key (default value is "en")

public setSoundexLang(string $str) : object
Parameters
$str : string

Soundex key language [ar|en]

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
object

$this to build a fluent interface

setSoundexLen()

Set the length of soundex key (default value is 4)

public setSoundexLen(int $integer) : object
Parameters
$integer : int

Soundex key length

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
object

$this to build a fluent interface

soundex()

Arabic soundex algorithm takes Arabic word as an input and produces a character string which identifies a set words that are (roughly) phonetically alike.

public soundex(string $word) : string
Parameters
$word : string

Arabic word you want to calculate its soundex

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Soundex value for a given Arabic word

standard()

This function will standardize Arabic text to follow writing standards (just like magazine/newspapers rules), for example spaces before and after punctuations, brackets and units etc .

public standard(string $text) : string

..

Parameters
$text : string

Arabic text you would like to standardize

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Standardized version of input Arabic text

str2int()

Convert Arabic idiom number string into Integer

public str2int(string $str) : int
Parameters
$str : string

The Arabic idiom that spells input number

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
int

The number you spell it in the Arabic idiom

stripHarakat()

Strip Harakat

public stripHarakat(string $text[, bool $tatweel = true ][, bool $tanwen = true ][, bool $shadda = true ][, bool $last = true ][, bool $harakat = true ]) : string
Parameters
$text : string

Arabic text you would like to strip Harakat from it.

$tatweel : bool = true

Strip Tatweel (default is TRUE).

$tanwen : bool = true

Strip Tanwen (default is TRUE).

$shadda : bool = true

Strip Shadda (default is TRUE).

$last : bool = true

Strip last Harakat (default is TRUE).

$harakat : bool = true

Strip in word Harakat (default is TRUE).

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Arabic string clean from selected Harakat

strtotime()

Arabic arStrToTime Function

public strtotime(string $text, int $now) : int

Function to parse about any Arabic textual datetime description into a Unix timestamp.

The function expects to be given a string containing an Arabic date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT), relative to the timestamp given in now, or the current time if none is supplied.

Parameters
$text : string

The string to parse, according to the GNU Date Input Formats syntax (in Arabic).

$now : int

The timestamp used to calculate the returned value.

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
int

Returns a timestamp on success, FALSE otherwise

swapAe()

Make conversion to swap that odd Arabic text by original English sentence you meant when you type on your keyboard (if keyboard language was incorrect)

public swapAe(string $text) : string
Parameters
$text : string

Odd Arabic string

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Normal English string

swapAf()

Make conversion to swap that odd Arabic text by original French sentence you meant when you type on your keyboard (if keyboard language was incorrect)

public swapAf(string $text) : string
Parameters
$text : string

Odd Arabic string

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Normal French string

swapEa()

Make conversion to swap that odd English text by original Arabic sentence you meant when you type on your keyboard (if keyboard language was incorrect)

public swapEa(string $text) : string
Parameters
$text : string

Odd English string

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Normal Arabic string

swapFa()

Make conversion to swap that odd French text by original Arabic sentence you meant when you type on your keyboard (if keyboard language was incorrect)

public swapFa(string $text) : string
Parameters
$text : string

Odd French string

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Normal Arabic string

utf8Glyphs()

Convert Arabic string into glyph joining in UTF-8 hexadecimals stream (take care of whole the document including English sections as well as numbers and arcs etc...)

public utf8Glyphs(string $text[, int $max_chars = 50 ][, bool $hindo = true ][, bool $forcertl = false ]) : string
Parameters
$text : string

Arabic string

$max_chars : int = 50

Max number of chars you can fit in one line

$hindo : bool = true

If true use Hindo digits else use Arabic digits

$forcertl : bool = false

If true forces RTL in the bidi algorithm

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
string

Arabic glyph joining in UTF-8 hexadecimals stream (take care of whole document including English sections as well as numbers and arcs etc...)

volc()

Determine if an Open Location Code is valid.

public volc(string $olc[, int $codeLength = 10 ]) : bool

Ref: https://github.com/google/open-location-code/blob/master/docs/specification.md

Parameters
$olc : string

Open Location Code string (e.g. 8G6RM7C7+PF)

$codeLength : int = 10

Code length, default value is 10 (this provides an area that is 1/8000 x 1/8000 degree in size, roughly 14x14 meters)

Tags
author

Khaled Al-Sham'aa khaled@ar-php.org

Return values
bool

String represents a valid Open Location Code.

Search results