Skip to content

Instantly share code, notes, and snippets.

@huzoorbux
huzoorbux / array.md
Created November 5, 2023 05:20
Array Exercises (PHP)

Array Exercises (PHP)

Questions

  1. If you have an array $a = array( 0, 1, 2, 3, 4 );, how do you extract the value 3 from the array?

  2. If you have an array $a = array( "zero"=>0, "one"=>1, "two"=>2, "three"=>3, "four"=>4 );, how do you extract the value 3 from the array?

  3. If you have the following array, how do you extract the value 3 from the array?

@huzoorbux
huzoorbux / utility_provider.html
Created January 13, 2021 13:01
USA Utility Provider HTML Drop Down
<select>
<option value='4 Change'>4 Change</option>
<option value='Acacia'>Acacia</option>
<option value='Adams Electric Coop'>Adams Electric Coop</option>
<option value='Adams Electric Coop, Inc.'>Adams Electric Coop, Inc.</option>
<option value='AECO (Alabama Electric Company)'>AECO (Alabama Electric Company)</option>
<option value='Aiken Electric Cooperative'>Aiken Electric Cooperative</option>
<option value='Alabama Power'>Alabama Power</option>
<option value='Alabama Rural Electric Association'>Alabama Rural Electric Association</option>
<option value='Alameda Municipal Power'>Alameda Municipal Power</option>
@huzoorbux
huzoorbux / strpos_multi.php
Created October 3, 2019 10:55
Search multiple words in a string it will return you occurred words.
<?php
function multi_pos($text,$search) {
$returnKey = array();
foreach($search as $keyword)
{
if(isset($keyword) && $keyword !="")
{
if(stripos($text, $keyword))
{
@huzoorbux
huzoorbux / downloadWordpress.php
Last active September 19, 2019 09:28
A simple PHP script that automatically downloads and unzips the latest version of Wordpress in the current directory (./), so that I don't have to download it and upload it to my server through FTP manually.
<?php
$url = "http://wordpress.org/latest.zip";
$zipFile = "wp.zip"; // Local Zip File Path
$zipResource = fopen($zipFile, "w");
// Get The Zip File From Server
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
@huzoorbux
huzoorbux / curlfunction.php
Created March 30, 2019 14:19
my curl method
public function runCurl($url, $post = null, $headers = null, $delete = null){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, $post == null ? 0 : 1);
if($post != null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if($delete != null) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "$delete");
}
@huzoorbux
huzoorbux / timezone.html
Created March 29, 2019 11:33
short timezone list
<select name="timezone" id="timezone" class="form-control select2">
<option value="">Select Timezone</option>
<option value="-12:00">Baker Island Time UTC-12:00</option>
<option value="-11:00">Samoa Standard Time UTC-11:00</option>
<option value="-10:00">Cook Island Time UTC-10:00</option>
<option value="-09:30">Marquesas Islands Time UTC-09:30</option>
<option value="-09:00">Alaska Standard Time UTC-09:00</option>
<option value="-08:00">Pacific Standard Time UTC-08:00</option>
<option value="-07:00">Mountain Standard Time UTC-07:00</option>
<option value="-06:00">Central Standard Time UTC-06:00</option>