how to remove line breaks using php code

how to remove line breaks?
how to remove carriage return and line feeds?
convert content in continuous line

When you are working with the php and export the data in the excel file or export to csv file then you will separate it with the \t and \n for the new lines, now if there is description or content which is text fields then its contains the HTML tags, line breaks and tabs. if you not remove this then it will not export proper data in the excel file, so its necessary to remove the line breaks from the content.

$data = trim(preg_replace('/\s+/','',strip_tags($data)));  

Using above code you get content in continuous line without line break and html code.

redirect on other domain when you load your page

Recently i am working with the google map and its working fine but after some days its not load the google map and redirect me on the other domain. if you facing the same problem then i have a solution for this. if there is any form which is in your site where user can insert the data like comments form or review form, if user insert the comment and its direct approval then its make this issue. below is one line code which you need to find in you entire web-page.

<META http-equiv="refresh" content="0;URL=">

Here, URL is the the domain on which you are redirected. if you found any code like this then remove it and your problem resolved.

how to set alt tag in images of post content in wordpress

You are working with the wordpress and post many article in your wordpress blog, in some article you are using the images and you insert it in the post content, when you upload the images then its go to the media gallery and then you inset it post and set as feature image, google can not fetch the images directly in its list, we need to set the alt tag in the images and google can read the alt tag from the images and then index that image in its list. once the alt tag is set in the image than google get idea regarding the image and then its set it and display in the images when any user search images.

Now, you did not set the alt tag when you insert the images in the post content and now there are many post in the blog, so its not possible to edit it one by one and set the alt tag to the image. Don’t worry i implement very easy way to set the alt tag in all the missing images.

function add_alt_tags_to_images($post_content)
global $post;
$post_content = str_replace('alt=""','alt="'.$post-&gt;post_title.'"', $post_content);
return $post_content;
add_filter('the_content', 'add_alt_tags_to_images', 99999);

You can put the above code in you function.php file which is in the theme folder of your wordpress blog. once you put this code in the function.php and run the blog then its set post title as the image alt tag in your site. Hope this will save your time and you enjoy it.


countdown timer using javascript

How to implement countdown timer using javascript?

Today i am working with one of the most important project and in this we need a timer countdown, if you look on the auction web-site then they show the time remaining to close the auction of the item, in that the time is working and its show on the page. this type of timer we can easily implement using the JavaScript.  here i share my code with you guys so you can not waste your time to implement this and use my code directly in your web site.

<table width=”100%” border=”0″ align=”center”>
<td align=”center” id=”displaytimerdays”>00</td>
<td align=”center” id=”displaytimerhh”>00</td>
<td align=”center” id=”displaytimermm”>00</td>
<td align=”center” id=”displaytimerss”>00</td>
<script language=”JavaScript”>
var TotalSeconds = 100;

function InitializeTimer(TimeInSeconds) {
TotalSeconds = TimeInSeconds;

window.setTimeout(“StartTickTick()”, 1000);

function StartTickTick() {
TotalSeconds -= 1;
window.setTimeout(“StartTickTick()”, 1000);

function SetUpdateTimer() {
var Seconds = TotalSeconds;

var Days = Math.floor(Seconds / 86400);
Seconds -= Days * 86400;

var Hours = Math.floor(Seconds / 3600);
Seconds -= Hours * (3600);

var Minutes = Math.floor(Seconds / 60);
Seconds -= Minutes * (60);

document.getElementById(“displaytimerdays”).innerHTML = LeadingZero(Days);
document.getElementById(“displaytimerhh”).innerHTML = LeadingZero(Hours);
document.getElementById(“displaytimermm”).innerHTML = LeadingZero(Minutes);
document.getElementById(“displaytimerss”).innerHTML = LeadingZero(Seconds);

function LeadingZero(STR) {

return (parseInt(STR) < 10) ? “0” + STR : + STR;

window.onload = InitializeTimer(5000);

Here, window.onload = IntialiseTimer(5000); function initialize the timer function and then its start the countdown. please let me know if you have any difficulties to implement this in your site.

How to sort a varchar field as numeric field in MySQL

How to sort a varchar field as numeric field in MySQL

How to sort a varchar field as integer field in MySQL

Sorting varchar field numerically in MySQL

MySQL provide the facility to sort the column in the SQL statement but some time we take field as a varchar and store integer or float values in that column, now when you sort it then it will sort it as alphabetically because we took that field type as varchar. now we need to sort it as numerically because we store the value in that field are integer or float.

we can do this using the type casting and update your SQL statement as below


Above statement sort your field as numerically even its varchar type, so this way you can sort string as numerically or sort string as number or sort string as numeric.

Some time solution is around us but we are not able to get it.


html editor for category description textarea in wordpress category

HTML Editor for Category Description Textarea.

HTML Editor for Tags Description Textarea.

HTML Editor for Taxonomies Description Textarea.

When you are working with the WordPress then you are aware that word press provide HTML editor to the post and page section only, WordPress do not provide the HTML editor for the category description, tag description or for any taxonomies description.

Rather then upload the editor externally on your site, you can use very easy way to get the html editor for the description fields of category, tags and taxonomies.

WordPress provide the ‘Rich Text Tags’ plugin which is easy to install, you just need to install it and no need to code any thing in the files. when you activate this plugin then its automatically apply on the category description text area.

Hope this save your time.

how to add new menu items in the wp-admin in wordpress

Create new menu items in the admin of wordpress

When you are working with the wordpress and you need to create custom menu in the admin panel of the wordpress then its really very easy. i will explain how to make the custom menu in the wordpress admin control panel.

Suppose you need to insert Main menu named PHP and then 2 sub menu in the main menu named php freelancer and freelancer php then you need to write below code in the function.php file, please make sure that you update the function.php file in the current theme.

add_action('admin_menu', 'register_custom_menu');
function register_custom_menu() {
	add_submenu_page("php developer", "php freelancer", "php freelancer", 'administrator', 'php freelancer', 'hire_php_developer');
	add_submenu_page("php developer", "freelancer php", "freelancer php", 'administrator', 'freelancer php', 'php_developer_hire');
    add_menu_page("PHP", "PHP", 'administrator', 'php developer', 'ci_generate_main_menu','','14');		

Here ci_generate_main_menu, hire_php_developer and php_developer_hire are the function which is called when you click on this menu item in the wp-admin, so you need to write all the html code which you need to display when this link is called and that html code will display in the right side of the page while the menu is in the left side of the page.

‘V’ Model used in the testing of software development

‘V’ Model

V-Model is one of the most powerful model which is used in the software development. V-Model is like the extension of the waterfall model, it means its better then the waterfall model. many models which is used currently in the software development are connected by the V-Model and as per the name V-Model, V describe the arrangement of all phases in the graphical shape of V. V used in the V-Model because its a synonym of validation and verification. Instead of moving down in a linear way, the process steps are bent upwards after the coding phase, to form the typical V shape. in the V-Model the order of the activities are in sequence and its provide better flow in the development and test activities. V- Model provide excellent relationship of each phases used in the system development life cycle.

Spiral Model used in the testing

Spiral Model

AS per the name the Spiral Model is cyclical and prototyping view of software development. Spiral Model test phase is divided in to stages and its covers risk analysis, validation of requirements and of the development of the system or application or software. In all the test we need to include module, integration and acceptance tests but in the Spiral Model testing its also follows the coding. In the Spiral Model first the design of the system is implemented and then the test plan implemented. If no activities associated with defects removal then its identifies by the spiral model.