Welcome! Log In Create A New Profile

Advanced

PHP7 - String Manipulation

Posted by Gaia77490614 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
PHP7 - String Manipulation
February 15, 2012 04:05PM
I have completed this section
avatar Re: PHP7 - String Manipulation
February 16, 2012 08:56PM
lets keep the ball rolling String. Section completed!
Re: PHP7 - String Manipulation
February 20, 2012 08:51PM
This is an excellent section!! Implode function makes exporting so easy!
Re: PHP7 - String Manipulation
February 24, 2012 08:46AM
I have finished this section and didn't have any problems
Re: PHP7 - String Manipulation
February 25, 2012 04:14PM
Complete
avatar Re: PHP7 - String Manipulation
February 25, 2012 09:14PM
I've completed this section.
Re: PHP7 - String Manipulation
February 29, 2012 03:32PM
Done
Re: PHP7 - String Manipulation
February 29, 2012 07:26PM
Done
Re: PHP7 - String Manipulation
February 29, 2012 09:42PM
Done n dusted,I never thought PHP will be this fun
Re: PHP7 - String Manipulation
March 03, 2012 12:12PM
owned this section
Re: PHP7 - String Manipulation
March 07, 2012 08:40PM
I have completed this section!
Re: PHP7 - String Manipulation
March 07, 2012 08:43PM
Here's a substr() example that checks an email address to see if ends in .com.

Language: PHP
<?PHP   $email = "test@test.com"; $email_end = substr($email, strlen($email) - 4);   if ($email_end = = ".com" ) { print "ends in .com"; } else { print "doesn';t end in .com"; }   ?>
Re: PHP7 - String Manipulation
March 07, 2012 08:56PM
str_word_count — Return information about words used in a string.

Language: PHP
<?php   $str = "Hello fri3nd, you';re looking good today!";   print_r(str_word_count($str, 1)); print_r(str_word_count($str, 2)); print_r(str_word_count($str, 1, ';àáãç3';));   echo str_word_count($str);   ?>

The above example will output:

Language: PHP
The above example will output:   Array ( [0] => Hello [1] => fri [2] => nd [3] => you';re [4] => looking [5] => good [6] => today ) Array ( [0] => Hello [6] => fri [10] => nd [14] => you';re [29] => looking [46] => good [51] => today ) Array ( [0] => Hello [1] => fri3nd [2] => you';re [3] => looking [4] => good [5] => today ) 7
Re: PHP7 - String Manipulation
March 08, 2012 08:35AM
For me to check for the .com i would use the ff.

Language: PHP
<?PHP $email = "test@test.com"; $needle = substr($email, strlen($email) - 4); echo strcmp($needle, substr($haystack, -1 * strlen($needle))) == 0 ? "Ends in .{$needle}" : "Does not";   ?>
Re: PHP7 - String Manipulation
March 09, 2012 12:29AM
Use of the similar_text function:

Language: PHP
<?php // Evaluate how closely "Abraham" matches the word "Adam" $str1 = "Adam"; $str2 = "Abraham"; $check_sim = similar_text($str1, $str2, $prcnt); echo "Similarity: $check_sim - Percentage: $prcnt%";   echo "<br /><br />";   // Evaluate how closely "Allen" matches the word "Adam" $str1 = "Adam"; $str2 = "Allen"; $check_sim = similar_text($str1, $str2, $prcnt); echo "Similarity: $check_sim - Percentage: $prcnt%"; ?>

Will output:
Language: PHP
Similarity: 3 - Percentage: 54.5454545455%   Similarity: 1 - Percentage: 22.2222222222%
Re: PHP7 - String Manipulation
March 09, 2012 12:40AM
Example of the str_repeat function:

Language: PHP
<?php echo str_repeat("-=", 10); ?>

This will produce:
Language: PHP
-=-=-=-=-=-=-=-=-=-=
Re: PHP7 - String Manipulation
March 09, 2012 07:56AM
Completed
Re: PHP7 - String Manipulation
March 09, 2012 09:48AM
Completedsmileys with beer
Re: PHP7 - String Manipulation
March 09, 2012 02:04PM
Completed
Re: PHP7 - String Manipulation
March 11, 2012 02:56PM
Finished this section.
Re: PHP7 - String Manipulation
March 11, 2012 04:42PM
Completed! grinning smiley
Re: PHP7 - String Manipulation
March 11, 2012 07:45PM
Finished string manipulationspinning smiley sticking its tongue out
Re: PHP7 - String Manipulation
March 11, 2012 09:47PM
Completed
Re: PHP7 - String Manipulation
March 12, 2012 12:59PM
Finishedthumbs up
Re: PHP7 - String Manipulation
March 12, 2012 01:35PM
I have completed this section
Re: PHP7 - String Manipulation
March 14, 2012 11:18AM
I have discovered something strange in my code.
If i compare the ff.

Language: PHP
$str1 = ';innocent';; $str2 = 0; if ($str1 == $str2) { echo ';String matched!';; }
This snippet of code display the result 'String matched!'.
I've learned that php engine first evaluate to the nearest form which is integer and compare using ==.
The better comparison operator is === which essentially checks even the type.
Re: PHP7 - String Manipulation
March 19, 2012 06:03AM
String section completed.
Re: PHP7 - String Manipulation
March 21, 2012 04:41PM
I have finished this section smiling smiley
Re: PHP7 - String Manipulation
April 11, 2012 10:50PM
My disc is missing files and as result I can't complete this section.
avatar
Mac
Re: PHP7 - String Manipulation
April 12, 2012 08:02AM
What files are missing? The only problem is that the html files on the CD has been updated, and that can be downloaded.
Sorry, you do not have permission to post/reply in this forum.