Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
by nikoloz nachkebia
3 years ago
0
PHP
Finds the Max of two numbers
0
Indexed array ptint_r var_dump
<?php

$colors = ["Red", 7735, "Blue"];
$colors[] = "Yellow";  //add new member in last position


echo $colors[0]; 

echo "\n\n\n";

print_r($colors);

echo "\n\n\n";

var_dump($colors);
OUTPUT:
Red


Array
(
    [0] => Red
    [1] => 7735
    [2] => Blue
    [3] => Yellow
)



array(4) {
  [0]=>
  string(3) "Red"
  [1]=>
  int(7735)
  [2]=>
  string(4) "Blue"
  [3]=>
  string(6) "Yellow"
}
by otar datuadze
3 years ago
0
PHP
0
function pyramid($n) {
 // number of spaces
 $k = $n;
 // outer loop to handle number of rows
 // n in this case
 for ($i = 0; $i < $n; $i++) {
	  // inner loop to handle number spaces values changing acc.
	  // to requirement
	  for ($j = 0; $j < $k; $j++) {
	   echo " ";
	  }
	 
	  // decrementing k after each loop
	  $k = $k - 1;
	 
	  // inner loop to handle number of columns
	  // values changing acc. to outer loop
	  for ($j = 0; $j <= $i; $j++ )
	  {
	   // printing stars
	   echo "* ";
	  }
	 
	  // ending line after each row
	  echo "\n";
	 }
}
 // Driver Code
 $n = 10;
 pyramid($n);
Outputs:
          1 
         1 1 
        1 1 1 
       1 1 1 1 
      1 1 1 1 1 
     1 1 1 1 1 1 
    1 1 1 1 1 1 1 
   1 1 1 1 1 1 1 1 
  1 1 1 1 1 1 1 1 1 
 1 1 1 1 1 1 1 1 1 1
by Levani Makhareishvili
3 years ago
0
PHP
Loops
2
โžค The gettype() function returns the type of a variable. Syntax:
gettype(variable);
For instance:
$int = 10;
echo gettype($int)."\n"; // outputs:  integer

$str = "PHP";
echo gettype($str)."\n"; // outputs:  string

$flt = 1.2;
echo gettype($flt)."\n"; // outputs:  double  (also called float)

$bool = true;
echo gettype($bool)."\n"; // outputs:  boolean

$arr = [1,2,3,4,5,6,7,8,9,10];
echo gettype($arr)."\n"; // outputs:  array
by Levani Makhareishvili
3 years ago
0
PHP
Function
1
<?php # variable echo " QUESTIONNAIRE :"; $giusha = "giusha"; $asaki = 24; $wona = 68.2; $simagle = 1.8; echo "\nMy name $giusha ๐Ÿ™‹๏ธ"; echo "\nMy age" ."$asaki ๐Ÿ”ฅ"; echo "\nMy weight $wona ๐Ÿ‹๏ธ "; print "\nMy height $simagle ๐Ÿง"; print "\n\n MY LOVING BREND :"; # array $brends = [ "Name"=>"BMW", "Name1"=>"MERCEDEC", "Name2"=> "toyota", ]; $brends ["no person"] = [true]; print_r ($brends); echo 'My lovd is :'. $brends ['Name1'] ."\n"; echo "\n When you born?"; $born = 1998; echo "\n\ni was born $born : 3 june"; ?>
by giorgi modebadze
3 years ago
0
PHP
#array
#array types
#string
0
// Manipulate on the two arrays with the same values both in PHP and JS.
// in PHP 
$array = [0, 1, 2];
$array2 = $array;
$array2[1] = 6;
array_push($array2, 3);
print_r ($array);
print_r($array2);
// $array = [0, 1, 2],    $array2 = [0, 6, 2, 3]
// In JS
let array = [0, 1, 2];
let array2 = array;
array2[1] = 6;
array2.push(3);
console.log(array);
console.log(array2);
// array = array2 = [0, 6, 2, 3]
// in JS It's the same array (since it's an object, it's the same reference), you need to create a copy to manipulate them separately // using slice() (or spread operator) in JS (which creates a new array with the elements at the first level copied over), like this:
let a = [0, 1, 2];
let b = a.slice();
b.push(3);
b[1] = 6;
console.log(a, b);
// and the result of 1st and 2nd arrays will not be same. like it wasn't in PHP
// P.s at that case will not change anything, because it's not reference already,
// we just took array's element, the primitive type (integer), not object or array.
let array = [0, 1, 2];
let value = array[1];
value = 10;
console.log(array);  // [0, 1, 2], will not change
console.log(value);    // 10
// but if there will be object, or array as an element in array and if we will modify on it, 
// than the main array will change the value as well.
const array = [{name: 'lela'}, {name: 'gela'}, {name: 'bela'}];
const object = array[0];
object.name = 'test';
console.log(array);
console.log(object);
by Luka Khitaridze
3 years ago
0
PHP
Array
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
3 years ago
0
PHP
Array
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
3 years ago
0
PHP
functions
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
3 years ago
0
PHP
Object Oriented PHP Tutorial
0
by nikoloz nachkebia
3 years ago
0
PHP
FOR loop examples
1
Results: 1578