how to retrieve from database..... this format (PRMRMDU402).
firstname= prabhu, lastname=kumar, city=madurai,
pincode=624402....

i want first name first two letters and last name last two
letters ... city first two letters ... pin code last three
letters....

Answer Posted / gaurav

$record = mysql_fetch_array(".........");
$fn = substr($record['firstname'], 0, 2);
$ln = substr($record['lastname'], -2);
$ct = substr($record['city'], 0, 2);
$pc = substr($record['pincode'], -2);

$final = strtoupper($fn.$ln.$ct.$pc);

echo $final;

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is factory pattern in php?

491


Can you explain, when to use if-else if-else over switch statements?

534


What type of operation is needed when passing values through a form or an url?

524


Which array function checks if the particular key exists in the array?

490


How to insert a line break in php string?

542






What is array function in javascript?

507


How to create an array of a group of items inside an html form?

567


What does the scope of variables means?

579


How do sessions work in php?

501


What is data type in php?

517


Do you know what's the difference between __sleep and __wakeup?

528


Write a statement to show the joining of multiple comparisons in php?

530


What is a closure in php?

533


What is csrf validation?

542


Explain NULL?

572