Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
loop array
$fruits =['apple', 'banana', 'mango']; foreach($fruits as $fruit){ echo $fruit. "<br>"; }
by guga muchiashvili
2 years ago
2
PHP
php note
0
More about array indexes CODE
It's possible to define keys only for some of the array items
$array = [1, 2, "name"=>"Three", 4];
print_r($array);
Result
Array
(
    [0] => 1
    [1] => 2
    [name] => Three
    [2] => 4
)
If we set higher index manually, it will continue adding 1 to the max index
$array = [1, 2, 7=>"Three", 4];
print_r($array);
Result
Array
(
    [0] => 1
    [1] => 2
    [7] => Three
    [8] => 4
)
If we set higher index manually, it will continue adding 1 to the index
$array = [1, 2, 7=>"Three", 4=>"forth", 25];
print_r($array);
Result
Array
(
    [0] => 1
    [1] => 2
    [7] => Three
    [4] => forth
    [8] => 25
)
Only integer and string values are allowed as array keys
$array = [
	1    => "a",
    "1"  => "b",
    "-1"  => "-b",
    '1.5'  => "c",
    true => "d",
];
print_r($array);
Result
Array
(
    [1] => d
    [-1] => -b
    [1.5] => c
)
by Valeri Tandilashvili
2 years ago
2
PHP
Arrays
0
array_push and print_r functions with arrays.
`
$items = array("me", "you", "he");

array_push($items, "she", "we");

print_r($items);
`
by Gigi Butchvelashvili
2 years ago
0
PHP
array
0
Date and Time CODE
`
Formats can be:

echo "Today is ". date("Y/m/d") . "\n";
echo "Today is ". date("d/m/Y"). "\n";
echo "Today is ". date("D/M/Y"). "\n";
echo "Today is ". date("d/M/Y"). "\n";
echo "Today is ". date("d.m.Y"). "\n";
echo "Today is ". date("d-m-Y"). "\n";
echo "Today is ". date("l"). "\n";
`
`
Output:
Today is 2022/10/22
Today is 22/10/2022
Today is Sat/Oct/2022
Today is 22/Oct/2022
Today is 22.10.2022
Today is 22-10-2022
Today is Saturday
`
by Gigi Butchvelashvili
2 years ago
0
PHP
0
by nikoloz nachkebia
2 years ago
0
PHP
"continue" Statement
0
by დავით ქუთათელაძე
2 years ago
0
PHP
logical operators
0
Variable types
string
$name = 'oto' ;
integer
$age = 32;
float
$height= 1.8;
booleean
$android = true;
array
$fruits = [apple , watermelon , orange ];
by otar datuadze
2 years ago
0
PHP
variable types
0
sum of number 1 to n
<?php

$x = 10;

// Sum of numbers from 1 to n
$sum = 0;
for ($i = 1;  $i <= $x;  $i++) {
	$sum += $i;
}
echo "SUM of numbers from 1 to $x: $sum\n";


// easy way to calculate SUM of numbers to n
$sum = $from1To * ($x+1) / 2;
echo "SUM of numbers from 1 to $x: $sum\n";
by Gvanca Gharibashvili
2 years ago
0
PHP
Object Oriented PHP Tutorial
0
some string functions
ფინქცია დააბრუნებს გარკვეულ ინფოს გადაცემულ ტექსტზე:
function str_info($string,$pos){
    $arr= ["length is: ". strlen($string),
           "UPPER:". strtoupper($string),
           "string possitin: " .strpos($string, $pos),
           "reverse is: ".strrev($string)];
    return implode("\n", $arr) ; // აქ შეაერთებს მასივის ელემენტებს და დააბრუნებს ტექსტის სახით
შედეგი length is: 13 UPPER:YOU ARE GREAT string possitin: 4 reverse is: taerg era uoY
by Guram Azarashvili
2 years ago
0
PHP
functions
0
Array random numbers
მასივში ჩაწერს მითითებული დიაპაზონის (0-100) შემთხვევითად გენერირებულ რიცხვებს:
<?php
$arr=[];
for ($i=0; $i<10; $i++){
    $arr[$i]= rand(0,100);  
}
print_r($arr);
by Guram Azarashvili
2 years ago
0
PHP
Array
0
Results: 1580