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 | |
echo strRevCha("Take a string, then for every words we reverse the order of character."); | |
/** | |
* Take a string, then for every words we reverse the order of character. | |
* | |
* @param String $str a string | |
* @return String|null $strOutput | |
* @author Phan Vu Hoang <[email protected]> |
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 | |
/** | |
* return backward read primes | |
* | |
* Find all Backwards Read Primes between two positive given numbers | |
* (both inclusive), the second one being greater than the first one. | |
* The resulting array or the resulting string will be ordered | |
* following the natural order of the prime numbers. | |
* |
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 | |
class Automobile | |
{ | |
private $vehicleMake; | |
private $vehicleModel; | |
public function __construct($make, $model) | |
{ | |
$this->vehicleMake = $make; |
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 | |
/** | |
* You'll have to translate a string to Pilot's alphabet (NATO phonetic alphabet) wiki. | |
* | |
* @author Phan Vu Hoang <[email protected]> | |
*/ | |
function to_nato($words) { | |
$lib['a']="Alpha"; |
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 | |
/** | |
* return a boolean true if all rotations of strng are included in arr (C returns 1) | |
* | |
* @param string $s | |
* @param array $arr | |
* @return boolean | |
* @author Phan Vu Hoang <[email protected]> | |
*/ |
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 | |
/** | |
* check whether an array can be turn to non-descending order by a single swap 2 elements | |
* | |
* @param array $a | |
* @return bool | |
* @author Phan Vu Hoang <[email protected]> | |
*/ | |
function solution($a) |
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 | |
/** | |
* return the max words of sentences, which is from a text | |
* | |
* @param $s | |
* @return mixed | |
* @author Phan Vu Hoang <[email protected]> | |
*/ | |
function solution($s) |
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 | |
/** | |
* Convert a multi-dimensional, associative array to CSV data | |
* @param array $data the array of data | |
* @return string CSV text | |
*/ | |
function str_putcsv($data) { | |
# Generate CSV data from array | |
$fh = fopen('php://temp', 'rw'); # don't create a file, attempt | |
# to use memory instead |
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 | |
/** | |
* Replace With Alphabet Position | |
* | |
* @author Phan Vu Hoang <[email protected]> | |
*/ | |
function alphabet_position(string $str) { | |
$ar_pos = []; |
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 alphabet_position( $str ) { | |
$str = strtolower( $str ); | |
$alphabetChars = 'abcdefghijklmnoqrstuvwxyz'; | |
$report=[]; | |
foreach (str_split($str) as $char) { | |
$g = (strpos($alphabetChars, $char) !== false) ? strpos($alphabetChars, $char) : ''; | |
if ($g!=='') { |
OlderNewer