if (isLink($content[$i][$j])) {

					if (isImageLink($content[$i][$j])) {

						$image_src = create_image($content[$i][$j], "img");

						$cell = <<<HTML
							<td>
								<img {$image_src} {$img_style}></td></img>
							</td>
HTML;
					} else if (isNestedLink($content[$i][$j])) {

						$links = explode("!", $content[$i][$j]);

						$cell = <<<HTML
							<td><a style="color: {$cards_button_bg_color};" href="{$links[1]}" $open_links_in >{$links[0]}</a></td>
HTML;
					} else {
						
						//Checking if it's a link or a button

							if ($j == $table_button_column) {
														
							//Button HTML
								$table_button_text = explode("-", $content[0][$j])[0];

								$cell = <<<HTML
									<td><a {$open_links_in} href="{$content[$i][$j]}" style="background-color: {$cards_button_bg_color}; color: {$cards_button_text_color};" class="btn">{$table_button_text}</a></td>
HTML;
							} else {
							
							// Link HTML			
								$cell = <<<HTML
									<td><a style="color: {$cards_button_bg_color};" href="{$content[$i][$j]}" $open_links_in >{$content[0][$j]}</a></td>
HTML;
							}
					}
By PHPhillip, 2020-06-09 23:28:49
    foreach ($desired_components as $name => $junk) {
      list($component_value, $component_comments) = self::unpackPair($desired_components[$name]);
      $desired_components[$name] = self::packPair(round($component_value, 2), $component_comments);
    }
By Anonymous, 2018-01-10 09:01:18
$url = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22https%3A%2F%2Fwww.google.com%2Ffinance%3Fq%3D' . $stock_identifier . '%26fstype%3Dii%26ei%3DCFrdWImFNdiGe_atlegC%22%20and%20compat%3D%22html5%22%20and%20xpath%3D' . "'%2F%2Ftable%5Bcontains(%40class%2C%22gf-table%20rgt%22)%5D'" . '&format=json&diagnostics=true&callback=';

$json = json_decode($this->getJsonFromYql($url), true);
$json = $json["query"]["results"]["table"];

//If the value is red, that means there is an additional span class which needs to be checked through. 

$response["revanueValue"] = empty($json["1"]["tbody"]["tr"]["0"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["0"]["td"]["1"]["span"]["content"] : $json["1"]["tbody"]["tr"]["0"]["td"]["1"]["content"];
$response["costofRevanue"] = $json["1"]["tbody"]["tr"]["3"]["td"]["1"]["content"];
$response["operatingIncome"] = empty($json["1"]["tbody"]["tr"]["12"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["12"]["td"]["1"]["span"]["content"] : $json["1"]["tbody"]["tr"]["12"]["td"]["1"]["content"];
$response["netIncome"] = empty($json["1"]["tbody"]["tr"]["24"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["24"]["td"]["1"]["span"]["content"] : $json["0"]["tbody"]["tr"]["24"]["td"]["1"]["content"];
$response["dividendsPerShare"] = $json["1"]["tbody"]["tr"]["35"]["td"]["1"]["content"];
$response["dilutedNormalizedEps"] = empty($json["1"]["tbody"]["tr"]["48"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["48"]["td"]["1"]["span"]["content"] : $json["1"]["tbody"]["tr"]["48"]["td"]["1"]["content"];
$response["minorityInterest"] = $json["1"]["tbody"]["tr"]["18"]["td"]["1"]["content"];

Website --> Json --> PHP Parsing Beautiful.

By Great PHP User, 2018-01-01 01:58:30
public override List<Value> Values
{
    get 
    {
        if (_values == null && shouldLoadLazily)
        {
            _values = _lazerLoader.LoadValues<Value>()
        }
        
        return _values;
    }
    set 
    {
        throw new InvalidOperationException("Values are actually readonly- please set in constructor")
    }
}

How to create immutable fields in c#

By Unknown, 2017-12-12 14:42:38
/**
 * Creates hash of client/customer password
 * @param string $password The actual password
 * @return string MD5 hash of password with salt
 */
public static function hashPassword($password)
{
	return md5($password . $password. 'SOME-SECRET-STRING' . $password);
}
By Anonymous, 2018-02-21 13:22:27
$orderDateTS = strtotime($data['ordertime']);
$nowTS = strtotime('now');
$diff = $nowTS - $orderDateTS;
$diff = $diff / 86400;
$dayDiff = floor($diff);

found in a shopware plugin

By Anon, 2020-04-03 14:16:07
// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

Never, ever define developer environment and debug as default thing! #pdk

By kadet, 2021-03-08 23:28:18
<?php
if(!defined('WPINC')) // MUST have WordPress.
	exit ('Do not access this file directly.');
	
	if(!class_exists('pluginName_options_page_class'))
{
	/**
	 * Menu page blah
	 *
	 * @package blah
	 * @since 140617
	 */
	class pluginName_options_page_class
	{
		public function __construct()
		{
			echo '<div class="wrap menu-page">'."\n";

			echo '<div class="wp-header-end"></div>'."\n";

			echo '<div class="menu-page-toolbox">'."\n";
			pluginName_some_other_class::display();
			echo '</div>'."\n";

			echo '<h2>Options</h2>'."\n";

			echo '<table class="menu-page-table">'."\n";
			echo '<tbody class="menu-page-table-tbody">'."\n";
			echo '<tr class="menu-page-table-tr">'."\n";
			echo '<td class="menu-page-table-l">'."\n";

			echo '<form method="post" name="plugin_options_form" id="plugin--options-form" autocomplete="off">'."\n";
			echo '<input type="hidden" name="plugin_options_save" id="plugin--options-save" value="'.esc_attr(wp_create_nonce('plugin--options-save')).'" />'."\n";

			echo '<div class="menu-page-group" title="Account Details">'."\n";
			
			/* includes things like this gem */
			echo (!is_multisite() || !pluginName_utils_conds::is_multisite_farm() || is_main_site()) ? '<p>[ Really Long message about something ]</p>'."\n" : '';

			/* ... continues until end ... */

			echo '</div>'."\n";
		}
	}
}

new pluginName_options_page_class ();

The entire file is a single class with a constructor. The constructor is ~ 1150 lines of echo statements with a few PHP conditionals thrown in. There are no other methods. The class is instantiated as soon as it is defined. Clever...

By Anonymous, 2020-11-10 06:08:16
if(!isset($obj->{'s5_4-1'})) {
	$obj->{'s5_4-1'} = 0;
}
if(!isset($obj->{'s5_4-2'})) {
	$obj->{'s5_4-2'} = 0;
}
if(!isset($obj->{'s5_4-3'})) {
	$obj->{'s5_4-3'} = 0;
}
if(!isset($obj->{'s5_4-4'})) {
	$obj->{'s5_4-4'} = 0;
}
By Anonymous, 2017-02-14 20:33:40
function prepareKeyword($keyword) {
    $keyword  = html_entity_decode($keyword);
    $keyword  = html_entity_decode($keyword);
    $keyword  = html_entity_decode($keyword);
    $keyword  = iconv("ISO-8859-1", "UTF-8", $keyword);
    $keyword  = cleanString($keyword);
    $keyword  = html_entity_decode($keyword);
    if ($keyword != "") {
        $keyword = mb_strtolower($keyword, "UTF-8");
        $keyword = htmlentities($keyword, ENT_HTML5);
    }
    return $keyword;
}
By Anonymous, 2017-12-15 22:05:55
function focused(evt, errors) {
	let form = evt.target

	const output = errors.map((error)=> {

		// Find first component with error on form and set focus to it

		let focusedInput = (Object.keys(error) == "phonebookId") ? Object.keys(error) :
			(Object.keys(error) == "phonebook_str") ? Object.keys(error) :
				(Object.keys(error) == "message") ? Object.keys(error) :
					(Object.keys(error) == "image") ? Object.keys(error) :
						(Object.keys(error) == "buttonLink") ? Object.keys(error) :
							(Object.keys(error) == "messageSms") ? Object.keys(error) : false
		return focusedInput.shift()
	})

	const selector = output.shift()
	form.querySelector('[id="' + selector + '"]').focus()

	return selector

Shitcode

By Anonymous, 2021-05-28 01:16:05
public static function getUser(){
    return \App\Models\User::all();
}
By mamadSiah, 2022-02-23 14:35:19
if ($customerId > 0) {
    $customerId = $customerId;
} else {
    $customerId = $this->customerSession->getId();
}
By Anonymous, 2018-01-10 16:42:14
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
while (true) {
  if ($current === $requested) {
     break;
  }
  if (! in_array($requested, $available)) {
     break;
  }
  session()->put('locale', $requested);
  break;
}
By Ed, 2020-08-05 15:26:32