Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
<?php

echo ohmsLaw_1(12, 220, "")."\n";
echo ohmsLaw_1(230, "", 2) ."\n";
echo ohmsLaw_1("", 220, 0.02) ."\n";
echo ohmsLaw_1("", "", 10)."\n";
echo ohmsLaw_1(500, 50, 10)."\n";

function ohmsLaw_1($voltage, $resistance, $current) {
	if ($voltage == "" && $resistance == "" ||
		$voltage == "" && $current == "" ||
		$resistance == "" && $current == "" ||
		$voltage != "" && $resistance != "" && $current != "") {
		return "Invalid";
	}

	if ($voltage == "") {
		$res = $resistance*$current;
	}

	if ($resistance == "") {
		$res = $voltage/$current;
	}
	if ($current == "") {
		$res = $voltage/$resistance;
	}

	return $res;
}

//using empty function
function ohmsLaw_2($voltage, $resistance, $current) {
	if (empty($voltage) && empty($resistance) ||
		empty($voltage) && empty($current) ||
		empty($resistance) && empty($current) ||
		!empty($voltage) && !empty($resistance) && !empty($current)
	) {
		return "Invalid";
	}

	if (empty($voltage)) {
		$res = $resistance*$current;
	}
	if (empty($resistance)) {
		$res = $voltage/$current;
	}
	if (empty($current)) {
		$res = $voltage/$resistance;
	}
	return round($res, 2);
}
by ვაჟა ტყემალაძე
1 year ago
0
PHP
Problem Solving
PHP Object Oriented Programming (OOP)
0
<?php

print_r(twoSum([4,4], 8));
print_r(twoSum([3,2,4], 6));
print_r(twoSum([1,3,4,2], 6));
print_r(twoSum([2,11,7,15], 9));
print_r(twoSum([-1,-2,-3,-4,-5], -8));

function twoSum($nums, $target){
	$cnt=count($nums);
	
	for ($i=0; $i<$cnt-1; $i++){
		for ($j=$i+1; $j<$cnt; $j++){
			
			if ($nums[$i]+$nums[$j]==$target){
				
				return [$i, $j];
			}
		}
	}
	
}
by ვაჟა ტყემალაძე
1 year ago
0
PHP
Problem Solving
PHP Object Oriented Programming (OOP)
0
file_get_contents timeout
Default
time limit
for
file_get_contents
is 60 seconds which we can increase using
timeout
property of
http
object
$opts = [
    "http" => [
        "method" => "GET",
        "timeout"=> 1200,
        "header" => 
            "Channel-Name: ".CHANNEL."\r\n" .
            "Authorization: ".AUTHORIZATION."\r\n"
    ]
];
// DOCS: https://www.php.net/manual/en/function.stream-context-create.php
$context = stream_context_create($opts); //, false, $context

$startTime = microtime(1);
$res = file_get_contents($url . $query, false, $context);
by Valeri Tandilashvili
1 year ago
0
PHP
0
cd <file name>
cd File Name
_ enters a new directory with addres
by ვაჟა ტყემალაძე
1 year ago
0
Git
note
Git Tutorial - Learn Command-line Git & GitHub
0
git clone
git clone <repository addres copied>
downloading entire projects
by ვაჟა ტყემალაძე
1 year ago
0
Git
note
Git Tutorial - Learn Command-line Git & GitHub
0
git push
git push
a repository goes to next commit
by ვაჟა ტყემალაძე
1 year ago
0
Git
note
Git Tutorial - Learn Command-line Git & GitHub
0
changes
before changes, we call comand
git status
, after chaNGING SOMETHING IN FILE. THEN WE CALL
GIT COMMIT -M <>
COMMAND
by ვაჟა ტყემალაძე
1 year ago
0
Git
note
Git Tutorial - Learn Command-line Git & GitHub
0
remote repository
In order to implement changes from git to github, we should create a remote repository, any kind of name we want
by ვაჟა ტყემალაძე
1 year ago
0
Git
note
Git Tutorial - Learn Command-line Git & GitHub
0
git add .
git add .
adds all new commits and changes in directory
by ვაჟა ტყემალაძე
1 year ago
0
Git
note
Git Tutorial - Learn Command-line Git & GitHub
0
git commit -m <file name>
git commit -m <file name>
makes changes in file repository
-m
means new change commit It's command for each new commit
by ვაჟა ტყემალაძე
1 year ago
0
Git
Git Tutorial - Learn Command-line Git & GitHub
0
Results: 1578