Pramod T P

Search
Skip to content
  • Home
  • PHP
  • WordPress
  • Linux
  • Magento
  • My SQL
  • Profile
  • comments

Daily Archives: May 22, 2012

PHP

strcmp()

May 22, 2012 Pramod T P

It compares two strings

Example

<?php
if (strcmp(“phpcode”, “PHPCode”) == 0) {
echo ‘Strings are equal’;
}else{
echo ‘Strings are not equal’;
}
?>

Output

Strings are not equal

FunctionsPHPString
PHP

strchr()

May 22, 2012 Pramod T P

Its an alias of strstr() and find the first occurrence of a string

Example

<?php
echo strchr(‘info@phpcodez.com’, ‘@’, true);
?>

Output

info

FunctionsPHPString
PHP

strcasecmp()

May 22, 2012 Pramod T P

It compares two strings (case-insensitive)

Example

<?php
if (strcasecmp(“phpcode”, “PHPCode”) == 0) {
echo ‘Strings are equal’;
}
?>

Output

Strings are equal

FunctionsPHPString
PHP

str_word_count()

May 22, 2012 Pramod T P

It return the number of words in a string

Example

<?php
echo “<pre>”;
print_r(str_word_count(‘It return the number of words in a string’));
?>

Output

9

FunctionsPHPString
PHP

str_split()

May 22, 2012 Pramod T P

It convert a string to an array

Example

<?php
echo “<pre>”;
print_r(str_split(‘phpcode’,2));
?>

Output

Array
(
[0] => ph
[1] => pc
[2] => od
[3] => e
)

FunctionsPHPString
PHP

str_shuffle()

May 22, 2012 Pramod T P

It randomly shuffles a string

Example

<?php
echo str_shuffle(‘phpcode’);
?>

Output

oehppdc

FunctionsPHPString
PHP

str_rot13()

May 22, 2012 Pramod T P

It perform the rot13 transform on a string

Example

<?php
echo str_rot13(‘PHP Code’);
?>

Output

CUC Pbqr

FunctionsPHPString
PHP

str_replace()

May 22, 2012 Pramod T P

It replace all occurrences of the search string with another string

Example

<?php
echo  str_replace(“phpcodez”, “phpcode”, “phpcodez welcomes you”);
?>

Output

phpcode welcomes you

FunctionsPHPString
PHP

str_repeat()

May 22, 2012 Pramod T P

It repeats a string

Example

<?php
echo str_repeat(“php code”, 5);
?>

Output

php codephp codephp codephp codephp code

FunctionsPHPString
PHP

str_pad()

May 22, 2012 Pramod T P

It pads a string to a certain length with another string

Example

<?php
echo str_pad(“phpcode”,20,”z”);
?>

Output

phpcodezzzzzzzzzzzzz

FunctionsPHPString

Posts navigation

← Previous 1 2 3 … 6 Next →

Zend | Magento Certified PHP | eCommerce Architect

For Latest Updates
Visit phpcodez.com

Categories

Recent Posts

  • Regular expression
  • preg_match
  • Redirect root domain to a subdomain .htaccess
  • Redirect root domain to a subfolder .htaccess
  • Force SSL htaccess
May 2012
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  
« Apr   Jun »

Recent Comments

togel online's avatartogel online on How to terminate the current s…
business funding's avatarbusiness funding on compare two strings – ja…
unsecured loans uk's avatarunsecured loans uk on Function to add an element int…
treating back pain's avatartreating back pain on Submit HTML form to pop up pag…
Pura Cleanse's avatarPura Cleanse on Add the block "Based on y…
  • RSS - Posts
Blog at WordPress.com.
Pramod T P
Blog at WordPress.com.
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Subscribe Subscribed
    • Pramod T P
    • Already have a WordPress.com account? Log in now.
    • Pramod T P
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...