tel me any 2 regular expressions with example

Answer Posted / shyambabu

int ereg ( string $pattern , string $string [, array
&$regs ] )
Date Format:YYYY-MM-DD
if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date,
$regs)) {
echo "$regs[3].$regs[2].$regs[1]";
prints in dd.mm.yyyy format
} else {
echo "Invalid date format: $date";
}


string ereg_replace ( string $pattern , string
$replacement , string $string )

$num = '4';
$string = "This string has four words.";
$string = ereg_replace('four', $num, $string);
echo $string; /* Output: 'This string has 4 words.'

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of mysql_fetch_array in php?

511


What is the most common http method?

517


Why does php need server?

524


What is $globals php?

538


How would you declare a function that receives one parameter name hello?

521






Is it more secure to use cookies to trfer session ids?

517


What is variable give example?

558


What is the purpose of $_ session?

519


Is php pass by reference or value?

538


how to track user logged out or not? when a user is idle?

531


What does sign mean php?

561


Write a program to find a string is palindrome or not?

521


How long do php sessions last?

562


Does php have a future?

511


Is set in php?

547