<?php $email = 'firstname@mail.com'; $domain = strstr($email, '@'); echo $domain; // prints@mail.com ?>
Category Archives: PHP
Function to find out the substring of a string – PHP
<?php
echo substr('abcdef', 1, 3);
// bcd
?>
function to format the price – PHP
<?php $number = 5030; echo number_format($number); // 5,030 ?>
function to format the price – PHP
<?php $number = 5030; echo number_format($number); // 5,030 ?>
Function to read the character from the ASCII value – PHP
<?php echo chr(50).","; echo chr(55).","; echo chr(53); ?>
Remove spaces from the end of a string – PHP
<?php
echo rtrim("Test "); // Test
//Will remove the spaces from the end
?>
Remove spaces from the beginning of a string – PHP
<?php
echo ltrim(" Test"); // Test
//Will remove the spaces from the beginning
?>
Command to install PHP – Ubuntu Linux
sudo apt-get install php5
How to decode the data – PHP
<?php
$enData =base64_encode("First");
echo base64_decode($enData);//First
?>
How to encode the data – PHP
<?php
echo base64_encode("First");
?>