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
"Provincias": [{ | |
"id": "1", | |
"nombre": 'Pinar del Río', | |
"municipios":["Consolación del Sur", "Guane", "La Palma", "Los Palacios", "Mantua", "Minas de Matahambre", "Pinar del Río", "San Juan y Martínez", "San Luis", "Sandino", "Viñales"] | |
}, { | |
"id": "2", | |
"nombre": 'Artemisa', | |
"municipios":[ | |
"Alquízar", "Artemisa", "Bauta", "Caimito", "Guanajay", "Güira de Melena", "Mariel", "San Antonio de los Baños", "Bahía Honda", "San Cristóbal", "Candelaria"] | |
}, { |
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
/** | |
* Binary Search Uncentered with Callback | |
* This is the method of binary search calculating the exact pivote for the search. | |
* @param array $haystack | |
* @param $first | |
* @param $last | |
* @param $needle | |
* @param callable $callback | |
* @return bool | |
*/ |
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
/** | |
* Binary Search Uncentered | |
* This is the method of binary search calculating the exact pivote for the search. | |
* @param array $haystack | |
* @param $first | |
* @param $last | |
* @param $needle | |
* @return bool | |
*/ | |
function binary_search_uncentered(array $haystack, $first, $last,$needle){ |
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
/** | |
* Array unique in object | |
* @param $obj | |
* @return mixed | |
*/ | |
function object_unique($obj) | |
{ | |
$objArray = (array)$obj; | |
$objArray = array_intersect_assoc(array_unique($objArray), $objArray); |
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
/** | |
* Array unique callback | |
* @param array $arr | |
* @param callable $callback | |
* @param bool $strict | |
* @return array | |
*/ | |
function array_unique_callback(array $arr, callable $callback, $strict = false) | |
{ | |
return array_filter( |
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 quicksort( $array ) { | |
if( count( $array ) < 2 ) { | |
return $array; | |
} | |
$left = $right = array( ); | |
reset( $array ); | |
$pivot_key = key( $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
<?php | |
/* | |
* Parameters: | |
* $a - The sort array. | |
* $first - First index of the array to be searched (inclusive). | |
* $last - Last index of the array to be searched (exclusive). | |
* $key - The key to be searched for. | |
* $compare - A user defined function for comparison. Same definition as the one in usort |