Bugün: 08/10/2008. Hoşgeldiniz!

Nisan, 2008

<?

$test_data=array(0.5,6,12,17,2,0.3,9);

echo "<img src=http://chart.apis.google.com/chart?chtt=".urlencode("Code Kodu Deneme")."&cht=lc&chs=450×125&chd=".chart_data($test_data).">";

function chart_data($values) {

$maxValue = max($values);

$simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

$chartData = "s:";
for ($i = 0; $i < count($values); $i++) {
$currentValue = $values[$i];

if ($currentValue > -1) {
$chartData.=substr($simpleEncoding,61*($currentValue/$maxValue),1);
}
else {
$chartData.='_';
}
}

return $chartData."&chxt=y&chxl=0:|0|".$maxValue;
}

?>

kaynak: ordan burdan

Php - Url Parse (scripti, nasıl, nedir?)

Yazan: admin Tarih: Nisan - 15 - 2008

$url = "http://www.otelreferans.com/post.php?example=yes&text=foobar";
$url = parse_url($url);

print_r($url);
/*
will return this array:

[scheme] => http
[host] => www.otelreferans.com
[path] => /post.php
[query] => example=yes&text=foobar
*/

kaynak: ordan burdan

Php - Dosyaya Ek Yapmak (scripti, nasıl, nedir?)

Yazan: admin Tarih: Nisan - 15 - 2008

function write($path, $content, $mode="w+"){
if (file_exists($path) && !is_writeable($path)){ return false; }
if ($fp = fopen($path, $mode)){
fwrite($fp, $content);
fclose($fp);
}
else { return false; }
return true;
}

örnek :

write('test.txt', 'Test content');

kaynak: ordan burdan

$captchaFolder = 'temp/';

// Filetypes to check (you can also use *.*)
$fileTypes = '*.jpg';

// Here you can define after how many
// minutes the files should get deleted
$expire_time = 20;

// Find all files of the given file type
foreach (glob($captchaFolder . $fileTypes) as $Filename) {

// Read file creation time
$FileCreationTime = filectime($Filename);

// Calculate file age in seconds
$FileAge = time() - $FileCreationTime;

// Is the file older than the given time span?
if ($FileAge > ($expire_time * 60)){

// Now do something with the olders files…

print "The file $Filename is older than $expire_time minutes
";

// For example deleting files:
//unlink($Filename);
}

}

kaynak: ordan burdan

function listdir_by_date($path){
$dir = opendir($path);
$list = array();
while($file = readdir($dir)){
if ($file != '.' and $file != '..'){
// add the filename, to be sure not to
// overwrite a array key
$ctime = filectime($data_path . $file) . ',' . $file;
$list[$ctime] = $file;
}
}
closedir($dir);
krsort($list);
return $list;
}

örnek :

listdir_by_date('data/');

kaynak: ordan burdan

function IsIPValid($ip){

if (preg_match('/^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$/', $ip)){
return true;
}

return false;
}
örnek:

var_dump(IsIPValid('192.168.100.1'));
// => bool(true)

var_dump(IsIPValid('192…1'));
// => bool(false)

var_dump(IsIPValid('127001'));
// => bool(false)

var_dump(IsIPValid('127.0.0.1'));
// => bool(true)

kaynak: ordan burdan

function GetBetween($content,$start,$end){
$r = explode($start, $content);
if (isset($r[1])){
$r = explode($end, $r[1]);
return $r[0];
}
return '';
}

örnek :

GetBetween('foo test bar', 'foo', 'bar');

// –> returns ' test ';

kaynak: ordan burdan

function array_changecase($a, $c='l'){
return array_change_key_case($a,($c=='u') ?
CASE_UPPER : CASE_LOWER);
}

örnek
array_changecase(array("foO" => "bar", "noNe" => 1), 'u')

returns:<br/>array("FOO" => "bar", "NONE" => 1)

kaynak: ordan burdan

function apply_keys($arr, $keys){
$new = array();
while(list($key, $val) = each($arr)){
$nk = (isset($keys[$key])) ? $keys[$key] : $key;
$new[$nk] = $val;
}
return $new;
}

örnek :
apply_keys(array(0,1,2), array('a','b','c');

return array('a' => 0, 'b' => 1, 'c' => 2);

kaynak: ordan burdan

var str = 'AbCdEfGhIjKlMnOpQrStUvWxYz';var result = str.toLocaleUpperCase();document.writeln(result); // Outputs: ABCDEFGHIJKLMNOPQRSTUVWXYZ

kaynak: ordan burdan