Professional Documents
Culture Documents
PHP.... Part 3
PHP.... Part 3
The date/time functions allow you to get the date and time from the server where your
You can then use the date/time functions to format the date and time in several ways.
. النصيPHP الوقت الحصول على التاريخ والوقت من الخادم حيث يتم تشغيل برنامج/ تتيح لك دوال التاريخ
. الوقت لتنسيق التاريخ والوقت بعدة طرق/ يمكنك بعد ذلك استخدام دوال التاريخ
The date() function formats a local date and time, and returns the formatted date
string.
. وإرجاع سلسلة التاريخ المنسقة، على تنسيق التاريخ والوقت المحليينdate () تعمل الدالة
PHP Date and Time 3
The date/time functions allow you to get the date and time from the server where your
You can then use the date/time functions to format the date and time in several ways.
. النصيPHP الوقت الحصول على التاريخ والوقت من الخادم حيث يتم تشغيل برنامج/ تتيح لك دوال التاريخ
. الوقت لتنسيق التاريخ والوقت بعدة طرق/ يمكنك بعد ذلك استخدام دوال التاريخ
The date() function formats a local date and time, and returns the formatted date
string.
. وإرجاع سلسلة التاريخ المنسقة، على تنسيق التاريخ والوقت المحليينdate () تعمل الدالة
PHP Date and Time 4
Here are some of the most common date format characters and their values.
<?php
echo date('Y');
// Output — 2018
You can also use the date() function to output the time. Here are some of the most
a am/pm in lowercase am
A am/pm in uppercase AM
i minutes with leading zeros 09 or 15
s seconds with leading zeros 05 or 30
PHP Date and Time 7
<?php
echo date('h:i:s A');
// Output — 11:03:37 AM
The strtotime() function will be helpful when you want to convert different date and
The function can parse almost all kinds of datetime strings into timestamps.
مفيدة عندما تريد تحويل قيم مختلفة للتاريخ والوقت بتنسيق سلسلة إلى طابعstrtotime() ستكونالدالة
.زمني
.يمكن للوظيفة تحليل جميع أنواع سالسل التاريخ والوقت تقريبًا إلى طوابع زمنية
PHP Date and Time 11
PHP Date and Time 12
<?php
$some_time = strtotime("10 months 15 days 10 hours ago");
echo 'It was '.date('l', $some_time).' on '.date('d F, Y h:i:s', $some_time).'.';
// Output — It was Sunday on 29 October, 2017 03:16:46.
?>
PHP Date and Time 14
PHP Date and Time 15
PHP Date and Time 16
PHP Date and Time 17
PHP Array 18
An array is a special variable, which can hold more than one value at a time.
If you have a list of items (a list of car names, for example), storing the cars in single
An array can hold many values under a single name, and you can access the values by
Type of Arrays
The index can be assigned automatically (index always starts at 0), like this:
The count() function is used to return the length (the number of elements) of an array:
<?php
{ echo $cars[$x];
Associative arrays are arrays that use named keys that you assign to them.
Or:
<?php
?>
====================================================
<?php
?>
PHP Array 24
PHP Array 25
PHP Array 26
PHP Array 27
PHP Array 28
PHP Array 29
PHP Array 30
PHP Array 31
Functions of Array >>> array_change_key_case() 32
Syntax
array_change_key_case(array, case);
Functions of Array >>> array_change_key_case() 33
Functions of Array >>> array_chunk() 34
The array_chunk() function is used to split an array into arrays with size elements.
Syntax
Functions of Array >>> array_chunk() 35
<?php
Elements will be arranged from lowest to highest when this function has completed.
<?php
sort($subject);
} ?>
Functions of Array >>> sort() 38
Functions of Array >>> sort() 39
Functions of Array >>> sort() 40
Functions of Array >>> array_reverse() 41
The array_reverse() function is used to reverse the order of the elements in an array.
Syntax:
array_reverse(array , preserve_keys) ;
preserve :Optional. Specifies if the function should preserve the keys of the array or
true
false
Syntax
Parameter Values
?php
$fruits = array( 0 => 'Orange', 1=> 'Apple', 2 => 'Banana', 3 => 'Cherry');
The array_merge() function merges one or more arrays into one array
Syntax:
Parameters:
The array_shift() function is used to remove the first element from an array,
Syntax: array_shift(array_name)
The array_splice() function removes selected elements from an array and replaces it
array (Required) – The array whose fraction of elements you want to remove.
start (Required) – This parameter takes the position number of the element from where
length (Optional) – The length defines how many elements you want to remove from the
starting number. If length is omitted, removes everything from starting position to the
replacement (Optional) – If you specify an array into this parameter, then the removed
?php
print_r($array1) ; ?>
Functions of Array >>> array_shift() 51
?php
$fruits_list = array(0 => 'Orange', 1=> 'Apple', 2 => 'Banana',3 => 'Cherry');
print_r($fruits_list) ;
echo '</br>'.$result;
?>
Functions of Array 52
Functions of Array >>> array_splice() 53
?php
print_r($colors);
?php
print_r($removedEl); ?>
Functions of Array >>> array_splice() 55
Functions of Array >>> array_splice() 56
Functions of Array >>> array_splice() 57
Functions of Array >>> array_push() 58
The array_push() function is used to add one or more elements onto the end of an
<?php
$array1= array('Mathematics','Physics');
array_push ($array1,'Chemistry','Biology');
print_r($array1); ?>
Functions of Array >>> array_push() 59
Functions of Array >>> implode() 60
Syntax
Syntax