Browsing articles from "February, 2010"
Feb
27
2010

String dd-mm-yyyy convert to date yyyy-mm-dd

<?php $date = "25-12-2010";//[something in US format: mm-dd-yy] $newdate = substr($date,6,4) . "-" . substr($date,3,2) . "-" . substr($date,0,2); print "\n=====\n".$newdate."\n===============\n"; ?>

Feb
27
2010

strrev – reversed string

<?php echo strrev("Hello world!"); // outputs "!dlrow olleH" ?>

Feb
24
2010

Search and replace within a field with regex in MySQL

SELECT * FROM ‘table’ WHERE `name` REGEXP ‘\r’ UPDATE ‘table’ SET ‘field’ = REPLACE(FIELD,"findvalue", "reaplcevalue") WHERE REGEXP ‘regexp search expression’

Feb
22
2010

UTF-8 connect to MySQL database

mysql_query("SET NAMES ‘utf8′ COLLATE ‘utf8_slovenian_ci’"); mysql_query("SET CHARACTER SET ‘utf8′;");

Feb
22
2010

How to change the collation for all tables in a MySQL database to UTF-8?

<?php $db = mysql_connect("localhost", "username", "pass"); if(!$db) echo "Cannot connect to the database – incorrect details"; mysql_select_db(‘myuser_mydbname’); $result=mysql_query(‘show tables’); while($tables = mysql_fetch_array($result)) { foreach ($tables as $key => $value) { mysql_query("ALTER TABLE $value COLLATE utf8_slovenian_ci"); }} echo "The collation of your database has been successfully changed!"; ?>

Feb
21
2010

Convert string from Windows-1250 to UTF-8

$string = iconv("CP1250", "UTF-8", $string);

Feb
21
2010

Disk Management and Win7 shortcut

Win+R -> diskmgmt.msc  -> Disk Management

Feb
18
2010

PHP Calculating script execution time

<?php $start = (float) array_sum(explode(‘ ‘,microtime())); // put you code that wanted to render at here $end = (float) array_sum(explode(‘ ‘,microtime())); echo "Processing time: ". sprintf("%.4f", ($end-$start))." seconds"; ?>

Pages:12»
Get Adobe Flash playerPlugin by wpburn.com wordpress themes