All posts by WhiteWind

About WhiteWind

I'm a Perl-PHP Developer from India. I'm a great fan of Wordpress & Perl.

How to replace a content in php?

It’s as folllows : –


<?php
$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
$onlyconsonants = str_replace($vowels, "", "Hello World of PHP");
?>

Add one day additional to a date in php

It’s as follows : –

 

$year=2013;
$month=04;
$date=12;
$newdate=date('Y-m-d H:i:s', strtotime($year."-".$month."-".$date." 00:00:00" . ' + 1 day'));

O/p :-

$new date will be “2013-04-13 00:00:00

How to get values(via some conditions) from the MySql table without using ‘OR’?

It can be done as follows :

SELECT * FROM `table_name` WHERE `request_id` IN ('value1','value2','value3','value4');

The benefit of using IN() is that it can process data more faster than using OR condition.

How to remove one element from the last of the array?

It’s as follows :

@coins = ("Quarter","Dime","Nickel");
pop(@coins);

O/p

@coins = Dollar Quarter Dime

How to add one element at the beginning of the array?

It’s as follows :

 


@coins = ("Quarter","Dime","Nickel");
unshift(@coins, "Dollar");

O/p

3. @coins = Dollar Quarter Dime Nickel