Skip to content

Instantly share code, notes, and snippets.

View dpaschenko's full-sized avatar

DP DESIGN PRO dpaschenko

View GitHub Profile
@dpaschenko
dpaschenko / Set a font size in header in PHPexcel.php
Last active March 19, 2018 22:05
Set a font size in header in PHPexcel
$objPHPExcel->getActiveSheet()->getHeaderFooter()
->setOddHeader('&C&H&25INTERVIEW WORKSHEET');
@dpaschenko
dpaschenko / Hreader and Footer Codes - PHPExcel.php
Created March 19, 2018 18:39
Hreader and Footer Codes - PHPExcel
@dpaschenko
dpaschenko / Count Array Values.php
Last active March 16, 2018 21:15
Count Array Values
array_count_values
//----------------------------------------------------------------------------------------------------------------------------------------------------------------
function array_icount_values($array) {
$ret_array = array();
foreach($array as $value) {
foreach($ret_array as $key2 => $value2) {
if(strtolower($key2) == strtolower($value)) {
@dpaschenko
dpaschenko / Unique Array.php
Created March 16, 2018 21:13
Unique Array
<?php
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>
@dpaschenko
dpaschenko / Get the first element of an array.php
Created March 16, 2018 21:12
Get the first element of an array
I USE: array_shift(array_values($array));
Original answer, but costly (O(n)):
array_shift(array_values($array));
In O(1):
array_pop(array_reverse($array));
Edited with suggestions from comments for other use cases etc...
<?php
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os)) {
echo "Got Irix";
}
if (in_array("mac", $os)) {
echo "Got mac";
}
?>
@dpaschenko
dpaschenko / Panel Collapsed.php
Created March 16, 2018 16:12
Panel Collapsed
<div class="panel panel-flat panel-collapsed">
@dpaschenko
dpaschenko / SQL Date Convert.php
Created March 15, 2018 17:59
SQL Date Convert
CONVERT(VARCHAR(10),RECORDS_ACTIONS.DTE ,101) As ActionDate,
@dpaschenko
dpaschenko / Remove Whitespaces & Blanks.php
Created February 27, 2018 17:18
Remove Whitespaces & Blanks
$customList = trim($customList);
$customList = str_replace(' ', '', $customList);
@dpaschenko
dpaschenko / if a string contains a specific word.php
Created December 16, 2017 02:06
if a string contains a specific word
$a = 'How are you?';
if (strpos($a, 'are') !== false) {
echo 'true';
}