php remove space inside string

You can remove space any where in string using regex preg_replace.preg_replace is function which work on regex to search and replace in string.Regular express is strong part of php.You can also search replace html tags.Here I have used regex string feature to search and replace space. Here is example how you can remove space anywhere in php $str = ‘nik

Read more

php get root path

$_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some. You can get root path in php using $_SERVER[‘DOCUMENT_ROOT’]. What is $_SERVER[‘DOCUMENT_ROOT’] ? The document root directory under which

Read more

php get date from timestamp

Its very easy in php to convert any valid timestamp value to php date time.The date() function and getdate() function do exactly what you required.here I am presensting some of example how to convert valid timestamp to php //php_get_date_from_timestamp.php $timestamp=time()-86400; //This is for just example Previouse day timestamp $date=date(“m/d/Y h:i:s A'”,$timestamp); echo $date; //another Way $DateArr=getdate($timestamp); echo $DateArr[‘mon’].’/’.$DateArr[‘mday’].’/’.$DateArr[‘year’].’ ‘.$DateArr[‘hours’].’:’.$DateArr[‘minutes’].’:’.$DateArr[‘seconds’] ;

Read more

php get url parameters

If you are looking for get url parameters in php then no need to write any logic or condition for getting it.Php has in built function called as “parse_url” this function return as array with parameter like host,path,query,fragment and more options.For more explanation please refer bellow given example. $url = ‘http://www.my-php-scripts.net/index.php?arg=value&args2=dfsdfsf#anchor’; print_r($url); This will return following Array ( [scheme] =>

Read more

php get filename without extension

If you are looking for how to get filename without extension then there is no need to do any coding or any logic for getting filename without extension simply you can use the php inbuilt function “pathinfo”.This function will return array with file info like extension,Filename without extension,Basename etc.For more info please refer bellow given example. $path_parts = pathinfo(‘/www/htdocs/index.html’); echo

Read more

php get current date

You can get current date in php using getdate().This function return array of options like seconds,minutes,hours,mday, and other options.You can also get date uing date function of php.Here i am presnting you some examples how to get current date in php. $dateArray=getdate();     echo “Current seconds=”.$dateArray[‘seconds’];    echo “Current minutes=”.$dateArray[‘minutes’];    echo “Current hours=”.$dateArray[‘hours’];    echo “Current mday=”.$dateArray[‘mday’];    echo “Current wday=”.$dateArray[‘wday’];    echo “Current

Read more

php get current timestamp

There is lots of way to get current timestamp. In php you can get current unix timestamp using time() function.Please use bellow given examples to get current unix timestamp. date_default_timezone_set(‘Asia/Calcutta’); //optional If PHP 5.3 generate Wornings then use it $cureentTimeStamp=time(); //current timestamp echo $cureentTimeStamp; echo ‘another Way’; echo strtotime(“now”);

Read more

wordpress font size tag cloud

The default font size for wordpress tag cloud is not well formated for all wordpress theme.So how to change wordpress theme tag cloud fontsize.There is a filter for wordpress called “widget_tag_cloud_args” In this filter you can apply font-size and many more options for wordpress tag cloud.   What you have to do is add given code into your current theme’s

Read more

remove image link wordpress

By defualt when you add image from gallery the link also added to the image.A link to image can be remove easy writing small code into function.php or creating plugin. Here is code for how to remove links from images add_filter(‘the_content’, ‘remove_images_from_post_page’); function remove_images_from_post_page($content){ $content = preg_replace(‘/]*>]*)><\/a>/im’, ”, $content); return $content; } add_shortcode( ‘gallery’, ‘remove_images_links_gallery’ ); function remove_images_links_gallery($attr) { global

Read more

magento search category name

Magento how to get category collection by name ? For example here we will get category by it name $category = Mage::getModel(“catalog/category”); $collection = $category->getCollection(); $collection->addAttributeToSelect(“*”); $collection->addFieldToFilter(“name”,array(“eq”=>’test’); The above code will fetch all category named “test”.

Read more
1 2 3 4 5 6 7