Posts

How to change or rename all file name in a folder in php?

If you want change or rename All file name or all images name in a folder so you can use this code and manipulate this code according to your need. <?php if ($handle = opendir('foldername1/')) {     echo "Directory handle: $handle\n";     echo "Files:\n";     /* This is the correct way to loop over the directory. */     while (false !== ($file = readdir($handle))) {     echo $file;    $newnameArr=explode('.',$file);// make sure in your file name there should not be . (full stop in File Name )     $Change_imageName = "yourchangename".$newnameArr[1];        echo $Change_imageName.'<p></p>';     rename( "foldername1/$file","foldername2/$Change_imageName");     }     closedir($handle); } ?> Note=> Where "Foldername1" is that folder where is images place now And "Foldername2" is that folder where images will take place after rename or change the filename. F

How to read all file name in a folder in php?

Read all file name in folder or Directory Here is the script which will return you all file name from a folder or Directory <? if ($handle = opendir ('cartColor-60-75/')) {     echo "Directory handle: $handle\n";     echo "Files:\n";     /* This is the correct way to loop over the directory. */     while (false !== ($file = readdir ($handle))) {         echo "$file";         echo '<p></p>';     }     /* This is the WRONG way to loop over the directory. */     while ($file = readdir($handle)) {         echo "$file<br/>";     }     closedir($handle); } ?>

How to get a string in excel with only first letter is capital and rest of string in small letter?

This code will give the right string in excel . In string First letter will be capital letter and rest of string will be in small letter. try this really works..... = UPPER (LEFT(A1,1))&LOWER(RIGHT(A1,LEN(A1)-1))

php interview question for 1-2 year experience

PHP-Mysql Interview Questions Q:1 How can we submit a form without a submit button? A:1 The main idea behind this is to use Java script submit() function in order to submit the form without explicitly clicking any submit button. You can attach the document.formname.submit() method to onclick, onchange events of different inputs and perform the form submission. you can even built a timer function where you can automatically submit the form after xx seconds once the loading is done (can be seen in online test sites). Q:2 In how many ways we can retrieve the data in the result set of MySQL using PHP? A:2 You can do it by 4 Ways 1. mysql_fetch_row. 2. mysql_fetch_array 3. mysql_fetch_object 4. mysql_fetch_assoc Q:3 What is the difference between mysql_fetch_object and mysql_fetch_array? A:3 mysql_fetch_object() is similar to mysql_fetch_array() , with one difference - an object is returned, instead of an array. Indirectly, that means that you can only

how to get the value of string between two word or charecter in string?

this function will return you the word or phrase in string which will come between two word or cherecter. function get_string_between($string, $start, $end) {     $string = " ".$string;     $ini = strpos($string,$start);     if ($ini == 0) return "";     $ini += strlen($start);     $len = strpos($string,$end,$ini) - $ini;     return substr($string,$ini,$len); } where $string is a string. $start is left word. $end is right word.

How to check if a string starts with a particular character in PHP?

You can use the substr  function in php and find the first character is exist in string or not if ( substr ( '_abcdef' , 0 , 1 ) === '_' ) { ... }

convert 10 digit timestamp to readable format in mysql

SELECT * , UNIX_TIME ( submitdate ) You should use  UNIX_TIME () function in mysql to convert timestamp to readable form