This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function clean($str) | |
{ | |
$str = utf8_decode($str); | |
$str = str_replace(" ", "", $str); | |
$str = preg_replace("/\s+/", " ", $str); | |
$str = trim($str); | |
return $str; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting( E_ALL ); | |
ini_set('display_errors', 1); | |
include 'Database.php'; | |
$db = new Database(); | |
$data = $db->getRecords(); | |
$newData = array(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// your code goes here | |
$array = array(1,2,2,4,5); | |
$uniqueme = array(); | |
$duplicates = array(); | |
foreach ($array as $key => $value) { | |
if( false == in_array($value,$uniqueme) ) { | |
$uniqueme[] = $value; | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; | |
$url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | |
echo $url; // Outputs: Full URL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
ini_set('display_errors', 1); | |
require_once './vendor/setasign/fpdi/pdf_parser.php'; | |
if( 1 == $_GET['file'] ) { | |
//file which we need to open in browser. | |
$filename="pdf_sample.pdf"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if( 1 == $_GET['file'] ) { | |
//file which we need to open in browser. | |
$filename="pdf_sample.pdf"; | |
$header="Content-Disposition: inline; filename=$filename;"; // Send File Name | |
} else { | |
//password protected file | |
$filename="pdf_sample_protected.pdf"; | |
$header="Content-Disposition: attachment; filename=$filename;"; // Send File Name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Calculating web content cache size…Calculating web content cache size… |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// your code goes here | |
// problem 01 solution | |
for($i=5;$i>=1;$i--) | |
{ | |
echo str_repeat('*',$i); | |
echo "\n"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findDuplicateNumber( $number ) | |
{ | |
$count = count($number); | |
$duplicateNumber = 0; | |
for( $i = 0; $i < $count; $i++ ) | |
{ | |
if( $number[abs($number[$i])] >= 0 ) { | |
$number[abs($number[$i])] = -$number[abs($number[$i])]; | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function reverse($str) | |
{ | |
for ($i = 0, $j = strlen($str) - 1; $i < $j; $i++, $j--) { | |
$tmp = $str[$i]; | |
$str[$i] = $str[$j]; | |
$str[$j] = $tmp; | |
$iteration++; |