$guard = ($vars->a_payment) + (0) * $price;
  if ($bless >= $guard) {
    $amount = $bless;
  }

Why not to write just 1 line?! $amount = max($bless, $vars->a_payment);

By Anonymous, 2018-02-05 17:27:25
if (isset($data['phone_id']) && !empty($data['phone_id'])) {
    $userPhone = $this->getDoctrine()->getRepository('STODBBundle:Phones')->find($data['phone_id']);
    if ($userPhone->getPhoneNumber() != $data['phone'] || $userPhone->getMobileProviderCode()->getId() != $data['phone_code']) {
        if ($data['smsCode'] ?? false) {
            if ($sessionSmsCode !== $data['smsCode']) {
                $aData['smsCodeShow'] = false;
                $aData['isWrongCode'] = true;
            } else {
                $aData['isWrongCode'] = false;
                $checkCode = $data['smsCode'];
            }
        } else {
            $aData['smsCodeShow'] = true;
            $aData['isWrongCode'] = true;
        }
    } elseif (!$userPhone->getCodeCheck()) {
        if ($data['smsCode'] ?? false) {
            if ($sessionSmsCode !== $data['smsCode']) {
                $aData['smsCodeShow'] = false;
                $aData['isWrongCode'] = true;
            } else {
                $aData['isWrongCode'] = false;
                $checkCode = $data['smsCode'];
            }
        } else {
            $aData['smsCodeShow'] = true;
        }
    } else {
        $aData['isWrongCode'] = false;
    }
} else {
    if ($data['smsCode'] ?? false) {
        if ($sessionSmsCode !== $data['smsCode']) {
            $aData['smsCodeShow'] = false;
            $aData['isWrongCode'] = true;
        } else {
            $aData['isWrongCode'] = false;
            $checkCode = $data['smsCode'];
        }
    } else {
        $aData['smsCodeShow'] = true;
    }
}

shit ... this junior

By sergma33, 2020-12-23 15:30:45
    if (preg_match("/^N/",$postcode)) {
        if (preg_match("/^NW/", $postcode)) {
            if (!preg_match("/^NW1/", $postcode)) {
                // NORTH WEST (NW2, NW3, NW4, NW5, NW6, NW7, NW8, NW9, NW10)
                $property['Prop_area'] = 'NW';
            } else {
                // NW1 which is Central
                $property['Prop_area'] = 'SW';
            }
        } else {
            // NORTH  (N1, N2, N3, N4, N5 etc)
            $property['Prop_area'] = 'N';
        }
    } else if (preg_match("/^W/",$postcode)) {
        if (
            !preg_match("/^W1 /",$postcode)
            && !preg_match("/^W2 /",$postcode)
            && !preg_match("/^W8/",$postcode)
            && !preg_match("/^W11/",$postcode)
        ) {
            // WEST includes (W3, W4, W5, W6, W7, W9, W10, W12, W13, W14)
            $property['Prop_area'] = 'W';
        } else {
            //W1 and W2, W8, W11 which are Central
            $property['Prop_area'] = 'SW';
        }
    } else {
        if (
            preg_match("/^SW/",$postcode)
            || preg_match("/^EC/",$postcode)
            || preg_match("/^WC/",$postcode)
        ) {
            // CENTRAL includes (W1, W2, EC, WC, NW1, SW1, SW3, SW5, SW7, W8, W11)
            $property['Prop_area'] = 'SW';
        } else {
            // OTHER includes South and East and everything else
            return 'SE';
        }
    }
By ichikawayukko, 2018-11-06 12:30:21
if ($customerId > 0) {
    $customerId = $customerId;
} else {
    $customerId = $this->customerSession->getId();
}
By Anonymous, 2018-01-10 16:42:14
#59 PHP +25
function mysql_escape_string($str) {
    
    $pattern = [
        '/\x00/',
        '/\n/',
        '/\r/',
        '/\//',
        "/'/",
        '/"/',
        '/\x1a/',
    ];
    
    $replacement = [
        '\\x00',
        '\\n',
        '\\r',
        '\\',
        "\'",
        '\"',
        '\\x1a',
    ];
    
    $res = preg_replace($pattern, $replacement, $str);
    return $res;
}
By Anonymous, 2016-02-13 18:22:55
private static function derivePrice(...)
  {
	$price = self::derivePriceUnchecked($vars);
    
    if (isset($price)) {
		// CODE HERE
    } 

    if (isset($price)) {
		// CODE HERE
    } 
    
    if (isset($price)) {
		// CODE HERE
    }

    if (isset($price)) {
		// CODE HERE
    }

    if (isset($price)) {
		// CODE HERE
    }

    if (isset($price)) {
		// CODE HERE
    }

    if (isset($price)) {
		// CODE HERE
    }

    if (isset($price)) {
		// CODE HERE
    }

    return $price;
  }
By Anonymous, 2018-02-06 11:38:18
<?php
$arr = [
    ["price" => 1],
    ["price" => 2]
];

$update = $arr;
$update[0]["price"] = 4;

$arr = $update;
By mamadSiah, 2021-05-11 11:06:19
$arrival_time = $obj->{'s1_6-2-'.strval($i).'date'} . ' ' . $obj->{'s1_6-2-'.strval($i).'time'} . ':00';
By Anonymous, 2017-02-14 20:31:36
public function get($paymentType, $carrier, $gds, $clearingCompany, $allowDirectPayment)
	{
		AcqData::preload();

		$carrier = strtoupper($carrier);
		if($paymentType == 'cc') {
			$gdsVal = $this->acqData->getGdsVal($gds);

			if(!$allowDirectPayment || 
			   !$gdsVal || 
			   !isset($gdsVal['lr'], $gdsVal['direct'], $gdsVal['lr_commission_acq'], $gdsVal['direct_commission_acq'])
			  ) {
				$ccDefaultVal = $this->acqData->getPaymentTypeVal($paymentType);
				return [[$ccDefaultVal, $ccDefaultVal], false];
			}

			$commission = $gdsVal['direct_commission_acq'];
			$isDirect = $this->isDirect($carrier, $gds, $clearingCompany);
			if(!$isDirect) {
				$gdsVal['direct'] = $gdsVal['lr'];
				$commission = $gdsVal['lr'];
			}

			return [
				[$gdsVal['direct'], $commission],
				$isDirect
			];
		}

		$paymentTypeVal = $this->acqData->getPaymentTypeVal($paymentType);

		return [
			[$paymentTypeVal, $paymentTypeVal], 
			false
		];
	}

$ccDefaultVal = $this->acqData->getPaymentTypeVal($paymentType); is duplicated in two branches...

By Anonymous, 2017-12-20 12:03:01
    $partnerChargesRegular = $row['charges'];
    $partnerChargesIrregular = $row['charges'];
    if (!isset($partnerChargesIrregular) || $partnerChargesIrregular == "") {
      $partnerChargesIrregular = $partnerChargesRegular;
    }

Look. We take A from X and B from X. Then, you make a check, and if it is true you assing A to B. BUT A AND B ARE TAKEN FROM THE SAME X PLACE!!! HOW CAN THEY DIFFER?!?!!!?!?!?!?!!

By My boss, 2018-02-20 10:06:53
in_array($this->market, ["ru"])

There is an old mysterious legend, which says that those conditions are lightening fast which are using in_array($source, ["target"]) instead of just "==". Is says always that probably you never do code refactoring, and keep all shit alive

By Anonymous, 2018-03-12 14:47:24
#1344 PHP +33
$command = 'curl -X GET -H "application/json" -H "X-Api-Key: '.$key.'" https://some-api.com/resource';
exec($command, $output);
$array = json_decode($output[0], true);

Using curl in PHP is boring. Let execute a command for

By Anonymous, 2020-07-14 20:28:49
$_POST = $this->db->mres($_POST);
$_SESSION['post'] = $_POST;

$sql = "SELECT id, documento, nombre1, nombre2, apellido1, apellido2 "
        . "FROM usuarios "
        . "WHERE " .
    "REPLACE(" .
        "REPLACE(" .
            "REPLACE(" .
                "REPLACE(telefono,' ','')," .
                "'(','')," .
            "')','')," .
        "'-','') LIKE '%{$searchTel}'";
By Carlos Correa, 2016-09-16 22:11:38
$net_price = "var net_price = " . json_encode($net_price) . ";";

This is a Javascript variable being created inside of a PHP string.

By notmycode, 2017-12-12 16:47:24
<?php

$payload = '{ "products": [';
foreach ($products as $product) {
    $payload .= $product->toJson() . ',';
}
$payload = substr($payload, 0, \strlen($payload) - 1);
$payload .= ']}';
By sijolas, 2019-03-15 14:47:06