Skip to content

Instantly share code, notes, and snippets.

<?php
for($i=1;$i<=112;$i+=3){
$sum+=$i;
echo $i." ";
}
echo "<br>$sum";
<?php
function parse_timestamp( $t = 0 )
{
//if you need to translate all the seconds in days or minutes
//you must delete this operation '%'
$day = ( $t / 86400 ) % 30;
$hour = ( $t / 3600 ) % 24;
$min = ( $t / 60 ) % 60;
<?php
echo "<pre>";
$y = date("Y");
$date = new DateTime("01.01.{$y}");
$flag = false;
$m = $date->format("m");
while ($date->format("Y") == $y)
{
if ($flag === false)
<?php
$arr = [1,1,2,3,4,5,5,6];
$result = array_unique($arr);
print_r($result);
<?php
foreach (range(1,6) as $array){
if($array%2!==0){
echo "Не четное число: $array <br>";
}else{
echo "Четное число: $array <br>";
}
}
<?php
$day = 6;
foreach (range(1, 7) as $weekDays) {
if ($weekDays == $day) {
if ($day < 6) {
$workDay = $weekDays;
}
if ($day >= 6) {
array_splice($weekDays, 4);
$weekendDay = $weekDays;
<?php
class Car{
public $model;
public $speed;
public $doors;
public $year;
public function __construct($model,$speed,$doors,$year)
{
def triangle_kind(a, b, c)
if a.equal?(b) && a.equal?(c)
p 'равносторонний'
elsif a.equal?(b) || a.equal?(c) || b.equal?(c)
p 'равнобедренный'
elsif right_trianle? a, b, c
p 'прямоугольный'
else
p 'чорт пойми шо'
end
def optimal(weight)
opti = weight - 110
if(opti < 0)
return "Твой вес уже в порядке"
else
return opti
end
end
def Discr(a,b,c)
d = (b*b)-4*(a*c)
return d
end
def Out(d,a,b,c)
if(d > 0)
x1 = (-b + Math.sqrt((b*b)-4*(a*c)))/(2*a)
x2 = (-b - Math.sqrt((b*b)-4*(a*c)))/(2*a)