if((substr($onefile, -4) == ".Mp3") OR
(substr($onefile, -4) == ".ogg") OR
(substr($onefile, -4) == ".OGG") OR
(substr($onefile, -4) == ".oGG") OR
(substr($onefile, -4) == ".OGg") OR
(substr($onefile, -4) == ".Ogg") OR
(substr($onefile, -4) == ".OgG") OR
(substr($onefile, -4) == ".mP3") OR
(substr($onefile, -4) == ".MP3") OR
(substr($onefile, -4) == ".mp3")){
// do stuff
}
gotta make sure you account for capitalization
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';
}
}
date('Y-m-d').'T'.date("H:i:s", strtotime("- 1 hour")).'Z'
Back to the future
<?php
$payload = '{ "products": [';
foreach ($products as $product) {
$payload .= $product->toJson() . ',';
}
$payload = substr($payload, 0, \strlen($payload) - 1);
$payload .= ']}';
try {
$order->addItem($item);
} catch (Exception $ex) {
throw $ex;
}
public function getProfilePicture(Company $company, $id, $url = null) {
// @TODO: Figure out how to do this.
return null;
}
//Говорящие названия - такие говорящие!
function asdfasdf (WebAPI_Entity $screenshot_dictionary)
{
$result = array();
foreach ($screenshot_dictionary->getEntities () as $scr)
{
$result [] = $scr->toObject ();
}
usort($result, array ($this, 'sortScreenshots'));
return $this->prepare_screenshots ($result);
}
// вставляем остальные скриншоты
$elements = $this->asdfasdf ($screenshot_dictionary);
<?php
class CasinoCode
{
CONST POST = 'POST';
CONST GET = 'GET';
$data = $this->callAPI('/hidden', [], self::POST);
production code of an API with dozens of millions of requests per day.
if ($getCount) {
foreach ($all_items as $item) {
$item_arr[$item->id] = 0;
}
return count($item_arr);
}
public function update($oldVersion) {
switch ($oldVersion) {
case '1.0.0':
case '1.0.1':
break;
default:
return false;
}
return true;
}
Found in a Shopware Plugin
$orderDateTS = strtotime($data['ordertime']);
$nowTS = strtotime('now');
$diff = $nowTS - $orderDateTS;
$diff = $diff / 86400;
$dayDiff = floor($diff);
found in a shopware plugin
{!! Form::select('ticket_category', \App\Models\Term::whereHas('taxonomy', function($query) {
$query->where('slug', 'ticket_category');
})->whereIn('id', ['15', '16', '17', '18'])
->pluck('name','id'), old('ticket_category'), [
'id' => 'ticket_category',
'class' => 'form-control',
'placeholder' => 'Seleccione una categoría']
)
!!}
to do it in an array if you can put it in the database so that you still burn the position
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;
}
}
$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
while (true) {
if ($current === $requested) {
break;
}
if (! in_array($requested, $available)) {
break;
}
session()->put('locale', $requested);
break;
}