PHP – iSSPL http://blog.inoxh.com Simple Solutions to a Simpler World. Fri, 01 Nov 2013 14:31:46 +0000 en-US hourly 1 https://wordpress.org/?v=4.6 How to change, switch between two images for anchor tag? http://blog.inoxh.com/how-to-change-switch-between-two-images-for-anchor-tag/ Sat, 27 Jul 2013 06:43:32 +0000 http://blog.inoxh.com/?p=281 < 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>]]> < 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>

]]>
Set PHP Date Time local to Asia/Calcutta (Indian Standard Time) http://blog.inoxh.com/set-php-date-time-local-to-asiacalcutta-indian-standard-time/ Tue, 11 Jun 2013 11:29:12 +0000 http://blog.inoxh.com/?p=273 $timezone = “Asia/Calcutta”;
date_default_timezone_set($timezone);
$date = date(‘Y-m-d’);
$time = date(‘H:i:s’);

]]>
How to read CSV (Comma Separated Files) line by line in PHP? http://blog.inoxh.com/how-to-read-csv-comma-separated-files-line-by-line-in-php/ Mon, 27 May 2013 05:16:57 +0000 http://blog.inoxh.com/?p=269 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);

]]>
How to remove part of string after certain character in php? http://blog.inoxh.com/how-to-remove-part-of-string-after-certain-character-in-php/ Tue, 21 May 2013 07:51:41 +0000 http://blog.inoxh.com/?p=266 $title = array_shift(explode(‘_’, $title));
where $title is string having complete text including ‘_’ , so it will remove any thing after ‘_’ including ‘_’.

]]>
How to get/pass Parameter from URL to Adobe Flash swf? http://blog.inoxh.com/how-to-getpass-parameter-from-url-to-adobe-flash-swf/ Sat, 18 May 2013 10:14:00 +0000 http://blog.inoxh.com/?p=244 Passing Parameters from URL in PHP

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

one= ]]> How to make a string’s first character uppercase in php? http://blog.inoxh.com/how-to-make-a-strings-first-character-uppercase-in-php/ Tue, 14 May 2013 08:03:53 +0000 http://blog.inoxh.com/?p=239 string ucfirst ( string $str )

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

]]>
How to get string from the last occurrence of the space in the string? http://blog.inoxh.com/how-to-get-string-from-the-last-occurrence-of-the-space-in-the-string/ Thu, 09 May 2013 08:32:32 +0000 http://blog.inoxh.com/?p=236
$string = substr($row[vodtitle],0,40);
$string = str_replace("-","",$string);
echo substr($string, 0, strrpos( $string, ' ') ); //Hello World
]]>
How to choose random number from a number range? http://blog.inoxh.com/how-to-choose-random-number-from-a-number-range/ Sat, 04 May 2013 05:05:28 +0000 http://blog.inoxh.com/?p=228 You can use

$range1 = rand(1, 100);
$range2 = rand(100, 200);
]]>
Looping through images in the folder http://blog.inoxh.com/looping-through-images-in-the-folder/ Sun, 21 Apr 2013 11:04:55 +0000 http://blog.inoxh.com/?p=222 name of the folder

$dt = $directory = “images/”;

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

}

]]>
PHP Code to check if its running on ‘localhost’ or not http://blog.inoxh.com/php-code-to-check-if-its-running-on-localhost-or-not/ Mon, 08 Apr 2013 11:22:37 +0000 http://blog.inoxh.com/?p=196 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
}
?>

]]>