1 0 Archive | PHP RSS feed for this section
post icon

How to change, switch between two images for anchor tag?

< a href="index.php">

< img src="images/home-grey.png" onmouseover="this.src='images/home-white.png'" onmouseout="this.src='images/home-grey.png'" />

< div class="big-text">Home< /div>

< /a>

Leave a Comment
post icon

Set PHP Date Time local to Asia/Calcutta (Indian Standard Time)

$timezone = “Asia/Calcutta”;
date_default_timezone_set($timezone);
$date = date(‘Y-m-d’);
$time = date(‘H:i:s’);

Leave a Comment
post icon

How to read CSV (Comma Separated Files) line by line in PHP?

CSV is plain text file, which means you can open it notepad or anyother text editor.
CSV file stores tabular data (numbers and text) in plain-text form.

$file_handle = fopen(“csv_file_name.csv”, “r”);

while (!feof($file_handle) ) {

$line_of_text = fgetcsv($file_handle, 1024);

print $line_of_text[0] . $line_of_text[1]. $line_of_text[2] . “
“;

}

fclose($file_handle);

Leave a Comment
post icon

How to remove part of string after certain character in php?

$title = array_shift(explode(‘_’, $title));
where $title is string having complete text including ‘_’ , so it will remove any thing after ‘_’ including ‘_’.

Leave a Comment
post icon

How to get/pass Parameter from URL to Adobe Flash swf?

Passing Parameters from URL in PHP

‘FlashVars’, ‘one=&two=‘,

one=

Leave a Comment
post icon

How to make a string’s first character uppercase in php?

string ucfirst ( string $str )

Returns a string with the first character of str capitalized, if that character is alphabetic.

Leave a Comment
post icon

How to get string from the last occurrence of the space in the string?

$string = substr($row[vodtitle],0,40);
$string = str_replace("-","",$string);
echo substr($string, 0, strrpos( $string, ' ') ); //Hello World
Leave a Comment
post icon

How to choose random number from a number range?

You can use

$range1 = rand(1, 100);
$range2 = rand(100, 200);
Leave a Comment
post icon

Looping through images in the folder

name of the folder

$dt = $directory = “images/”;

code to loop through each image in the folder
$images = glob($directory . “*.jpg”);
foreach($images as $image)
{

}

Leave a Comment
post icon

PHP Code to check if its running on ‘localhost’ or not

sometime we have to run two different code’s, one on local machine another set of code on live server.

So to check it

<?php
$url=”http://”.$_SERVER[‘HTTP_HOST’];
if($url == “http://localhost”)
{
//code to be run on local machine
}
else
{
// code to run on server machine
}
?>

Leave a Comment
April 8, 2013