admin

admin

PHP convert_cyr_string() Function

The convert_cyr_string() function converts a string from one Cyrillic character-set to another. The supported Cyrillic character-sets are: k – koi8-r w – windows-1251 i – iso8859-5 a – x-cp866 d – x-cp866 m – x-mac-cyrillic Example <?php $str = “Hello…

PHP chunk_split() Function

The chunk_split() function splits a string into a series of smaller parts. Note: This function does not alter the original string. Example <?php $str = “Hello world!”; echo chunk_split($str,1,”.”); ?> Output H.e.l.l.o. .w.o.r.l.d.!.

PHP chr() Function

The chr() function is used to get a single character string from the specified ASCII value. Return values: A one-character string containing the character specified by ascii _code Example <?php echo chr(52) . “<br>”; // Decimal value echo chr(052) .…

PHP chop() Function

The chop() function is used to remove the whitespaces and other predefined characters from the right side of a string. This function is an alias of rtrim() function. Example <?php $str = “Hello World!”; echo $str . “<br>”; echo chop($str,”World!”);…

PHP bin2hex() Function

The bin2hex() function converts a string of ASCII characters to hexadecimal values. The string can be converted back using the pack() function. Example $str = bin2hex(“Hello World!”); echo($str); Output 48656c6c6f20576f726c6421

PHP addslashes() Function

The addslashes() function is used to add backslashes in front of the characters that need to be quoted. The predefined characters are single quote (‘), double quote(“), backslash(\) and NULL (the NULL byte). Example <?php $str = addslashes(‘What does “hello”…

PHP addcslashes() Function

The addcslashes() function is used to add backslashes in front of the specified characters in a string. Note : In PHP \0 (NULL), \r (carriage return), \n (newline), \f (form feed), \v (vertical tab) and \t (tab) are predefined escape…

How to get AM/PM from a datetime in PHP

You need to convert it to a UNIX using strtotime and then back into the format you require using the date function. Use strtotime() to make the date a UNIX timestamp. Code <?php $date = ‘2018-01-31 10:43:23’; date(‘d-m-Y h:i A’,…

How to Dynamic Exporting to Excel by phpExcel

It is very common to have the list exportable to save live table. Doing this with online web list data is not that hard. We would like to recommend using phpExcel to get this work done. However, this tutorial not…

How to Convert date format yyyy-mm-dd => dd-mm-yyyy in PHP

Convert date from YYYY-MM-DD to DD-MM-YYYY (and from DD-MM-YYYY to YYYY-MM-DD). The timestamp which is used as a base for the calculation of relative dates. Use strtotime() and date() Code $Date = “2018-01-25”; $newDate = date(“d-m-Y”, strtotime($Date)); echo “New date…