<?xml version="1.0" encoding="UTF-8" standalone="no"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:gd="http://schemas.google.com/g/2005" xmlns:georss="http://www.georss.org/georss" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-2401702757274511569</atom:id><lastBuildDate>Tue, 04 Nov 2025 11:19:34 +0000</lastBuildDate><category>mysql documentation</category><category>my sql</category><category>mysql mac</category><category>mysql php</category><category>mysql tutorial</category><category>sql database</category><category>mysql</category><category>php</category><category>mysql view index</category><category>Altering Tables</category><category>Altering Tables in mysql</category><category>mysql foreign key</category><category>Case Sensitivity in String Comparisons</category><category>MySQL server</category><category>Perl-style regular expressions</category><category>SELECT</category><category>WHERE</category><category>joins</category><category>Binary String Type</category><category>REGULAR EXPRESSIONS</category><category>from</category><category>html</category><category>join</category><category>php control flow</category><category>update</category><category>web</category><category>web design</category><category>web designer</category><category>Basic Uses of SELECT</category><category>INFORMATION_SCHEMA</category><category>Modifying Columns</category><category>MySQL Query Browser</category><category>POSIX regular expressions</category><category>Quantifiers</category><category>Remembering the Session</category><category>Retrieving Data</category><category>Retrieving the Session Data</category><category>SQL Expressions</category><category>SQL JOINS</category><category>Selecting a Database</category><category>Table Properties in mysql</category><category>about my sql query browser</category><category>aliases in mysql</category><category>break statement in php</category><category>changing table name in mysql</category><category>create</category><category>creating tables in mysql</category><category>designer tools for web</category><category>how html works</category><category>how to build a website</category><category>how to manage a database</category><category>how to update values in mysql</category><category>insert</category><category>insert in mysql</category><category>insert query</category><category>insert statement</category><category>left join</category><category>mys</category><category>mysql connect</category><category>mysql data types</category><category>need tools for web</category><category>orderby</category><category>php and mysql</category><category>php mysql</category><category>right join</category><category>sample html</category><category>show</category><category>web components</category><category>web developer</category><category>web development tools</category><category>Aggregating Query Results</category><category>Array Sorting Function</category><category>Authentication</category><category>Authentication Variables</category><category>BIT Types</category><category>Brackets</category><category>Break and Continue in php</category><category>COLUMNS</category><category>CONCAT</category><category>Combining mysql_select_db() and mysql_query()</category><category>Comparing Strings</category><category>Comparing Two Strings</category><category>Comparison Functions</category><category>Connecting to MySQL</category><category>Construct Feedback in php</category><category>Counting Strings</category><category>Creating Databases</category><category>Creating Databases MYSQL</category><category>DISTINCT</category><category>DUPLICATE KEY</category><category>Data Encryption</category><category>Data Encryption  in php</category><category>Database Authentication</category><category>Database Components</category><category>Database Design</category><category>Database Information</category><category>Database Metadata</category><category>Database Properties</category><category>Decoding the Session Variables</category><category>Disconnecting from MySQL</category><category>Displaying Database Structure</category><category>Displaying Query Results</category><category>Displaying Table Creation Information</category><category>Displaying Table Creation Information  in mysql</category><category>Drop Tables</category><category>ERROR 1066 (42000)</category><category>ERROR 1066 (42000): Not unique table/alias: 'Country'</category><category>Emptying Tables</category><category>Emptying table name in mysql</category><category>Encoding the Session Variables</category><category>Encoding/Decoding Session Data</category><category>Error Information</category><category>Exclusive Data</category><category>Explicit object cloning</category><category>File-Based Authentication</category><category>Final</category><category>Final  method</category><category>Final classes</category><category>Fixed-Point Types</category><category>Floating-Point Types</category><category>HOW TO MANAGING DATABASES</category><category>HTML Conversion</category><category>HTML element</category><category>HTML to Text Conversion Functions</category><category>Hard-Coded Authentication</category><category>Hard-coded</category><category>IEEE POSIX 1003.2</category><category>INDEX</category><category>INSERT with NULL Values</category><category>INSERT with ON DUPLICATE KEY UPDATE Instead of REPLACE</category><category>Independent Connection Information</category><category>Indexing Tips</category><category>Integer Data Type</category><category>Integer Values</category><category>Interfaces</category><category>LAST_INSERT_ID</category><category>Limitations of Authentication Variables</category><category>Limitations of File-Based Authentication</category><category>Limitations of Hard-Coding</category><category>MANAGING DATABASE TABLES in mysql</category><category>MYSQL FOUNDATIONS</category><category>MYSQL_ASSOC</category><category>MYSQL_BOTH</category><category>MYSQL_NUM</category><category>Managing Database Tables</category><category>Managing Databases</category><category>Manipulating String Cases</category><category>Metacharacters</category><category>Modifiers</category><category>Modify String Length</category><category>Multi-Table  DELETE</category><category>Multi-Table UPDATE</category><category>Multi-Table UPDATE and DELETE</category><category>MySQL Error</category><category>MySQL Error Information</category><category>MySQL General Architecture</category><category>MySQL Handling Logins Example</category><category>MySQL Identifiers</category><category>MySQL Metadata</category><category>NULL</category><category>New Object-Oriented Features</category><category>Numeric Data Type</category><category>Numeric Expressions</category><category>Numeric Expressions in mysql</category><category>Other String Comparison Functions</category><category>PHP Authentication</category><category>PHP Functions for Retrieving Metadata</category><category>PHP MySQL API</category><category>PHP MySQL Function</category><category>PHP REGULAR EXPRESSIONS</category><category>PHP STRINGS</category><category>PHP Session Handling with MySQL</category><category>PHP script</category><category>PHP'S STRINGS AND REGULAR EXPRESSIONS</category><category>PHP's regular expressions</category><category>POSIX</category><category>POSIX ERE's</category><category>POSIX regular expressions(SQL)</category><category>PRIMARY KEY</category><category>Perl-style</category><category>Predefined</category><category>Querying MySQL</category><category>REPLACE Statement</category><category>Remove Columns</category><category>Renaming Tables</category><category>Replacing the Session Key</category><category>SCHEMATA</category><category>SELECT statement</category><category>SELECT statement in mysql</category><category>SELECT with DISTINCT</category><category>SELECT with LIMIT</category><category>SELECT with MySQL Query Browser</category><category>SELECT with ORDER BY</category><category>SELECT with WHERE</category><category>SESSION HANDLING</category><category>SQL DML Commands</category><category>SQL Parser</category><category>SQL SELECT Commands</category><category>Session Data</category><category>Session Handling Configuration Options</category><category>Session Handling Tasks</category><category>Setting up the Session Key</category><category>Starting a Session</category><category>Statement Terminators</category><category>Storage Engine Breakdown</category><category>Storage Engine Tier</category><category>Storage Engines</category><category>Storing Authentication Data</category><category>Storing MySQL Session Data</category><category>Storing the Session Data</category><category>String Comparison Functions</category><category>String Data Types</category><category>String Expressions</category><category>String Length</category><category>String comparisons</category><category>TABLE_SCHEMA</category><category>TIMESTAMP</category><category>Table Indexing</category><category>Table Metadata</category><category>Telling PHP to Remember a Visitor</category><category>Temporal Data Types</category><category>Temporal Data Types in mysql</category><category>Temporal Expressions</category><category>Temporal Expressions in mysql</category><category>Temporary Tables in mysql</category><category>Terminating a Session</category><category>Text String Type</category><category>The Process of Remembering a Visitor</category><category>The REPLACE Statement</category><category>The UPDATE Statement</category><category>The mysql Client</category><category>UNIQUE</category><category>UPDATE Instead of REPLACE</category><category>UPDATE Statement</category><category>UPDATE with ORDER BY</category><category>UPDATE with SET</category><category>Unix regular expressions</category><category>User Privileges</category><category>Using Aliases</category><category>Using DROP DATABASE in mysql</category><category>Using LIKE for Pattern Matching</category><category>Using POSIX regular expressions</category><category>Using Perl-style regular expressions</category><category>Using Qualifiers</category><category>Using Qualifiers and Aliases</category><category>Using mysql Interactively</category><category>Using the Database</category><category>Viewing MySQL Metadata</category><category>WEB DESIGN TEMPLATE</category><category>acronym for  newline to br tags special characters in HTML to their HTML equivalents</category><category>adding column</category><category>array</category><category>array_flip</category><category>arsort</category><category>attribute sort</category><category>basic clauses</category><category>bool sort</category><category>caution while droping database</category><category>client server architecture</category><category>column option in mysql</category><category>commenting in php</category><category>compare using php</category><category>connection</category><category>continue statement in php</category><category>converts each alphabetical character into its equivalent lower and upper case</category><category>cookie_domain</category><category>cookie_lifetime</category><category>cookie_path</category><category>count rows in mysql</category><category>count_chars</category><category>create table</category><category>data types in php</category><category>database</category><category>db</category><category>ddl</category><category>delete</category><category>delete a row</category><category>delete in mysql</category><category>delimiting php</category><category>designer tools dor web</category><category>divides strings based on the pattern</category><category>dml</category><category>do while in php</category><category>ereg</category><category>ereg_replace</category><category>eregi</category><category>eregi_replace</category><category>error</category><category>error status</category><category>example of mysqltables</category><category>example of preg_replace_callback()</category><category>feedback in php printf in php echo in php</category><category>file-based and database authentication.</category><category>find all occurrences</category><category>first character of each word in the string to uppercase</category><category>flow control in php</category><category>for statement</category><category>foreign key</category><category>foreign key clause</category><category>foreign key in mysql</category><category>gc_divisor</category><category>gc_probability</category><category>get_html_translation_table</category><category>how  to define  text string data types in mysql</category><category>how  to define string data types in mysql</category><category>how does inner join works</category><category>how does preg_split works</category><category>how does split works</category><category>how is date given in mysql</category><category>how to  compare two string</category><category>how to  places a backslash in front of all special regular expression characters</category><category>how to Emptying tables in mysql</category><category>how to Modifying  column in mysql</category><category>how to add column in mysql</category><category>how to aggregate using mysql</category><category>how to apply right join</category><category>how to chanege column clause in mysql</category><category>how to comment in php</category><category>how to communicate with mysql and php</category><category>how to concat using mysql</category><category>how to creat a table in mysql</category><category>how to create a database in mysql</category><category>how to create a foreign key in mysql</category><category>how to create temporary table in mysql</category><category>how to disconnect mysql</category><category>how to display result in php</category><category>how to do Table Indexing in mysql</category><category>how to do indexing in mysql</category><category>how to drop a database</category><category>how to drop tables in mysql</category><category>how to get in formation about mysql created tables</category><category>how to implement flow control in php</category><category>how to implement while in php</category><category>how to insert values  from another table in mysql</category><category>how to insert values in mysql</category><category>how to remove column in mysql</category><category>how to rename tables in mysql</category><category>how to replace values in mysql</category><category>how to see index in mysql</category><category>how to set collation in mysql</category><category>how to shuffle array</category><category>how to sort the key in an array</category><category>how to use delete</category><category>how to use distinct in mysql</category><category>how to use md5 in php</category><category>how to use orderby in mysql</category><category>how to use the database in mysql</category><category>how to use where in mysql</category><category>how to view data in mysql</category><category>how to view index</category><category>html introduction</category><category>html tags</category><category>htmlspecialchars</category><category>if</category><category>if else in php</category><category>in</category><category>ineer join</category><category>inner join in mysql</category><category>inner join keywords.using on in joins</category><category>insert with select</category><category>instance of operator</category><category>introduction</category><category>invoking functions</category><category>is mysql case sensitivity</category><category>joins in sql</category><category>key</category><category>key sort</category><category>keys in mysql</category><category>last insert id</category><category>left outer join</category><category>like in mysql</category><category>limit</category><category>ltrim</category><category>matching alphabetic characters</category><category>md5 in php</category><category>my sql column option</category><category>mysql Character Restrictions</category><category>mysql Database Design</category><category>mysql Database creation</category><category>mysql architecture</category><category>mysql enterprise</category><category>mysql foundation</category><category>mysql function</category><category>mysql gui tools</category><category>mysql introduction</category><category>mysql products</category><category>mysql table properties</category><category>mysql tables</category><category>mysql_close</category><category>mysql_connect</category><category>mysql_create_db</category><category>mysql_error()</category><category>mysql_fetch_object</category><category>mysql_fetch_row</category><category>mysql_numrows</category><category>mysql_result</category><category>mysql_select_db</category><category>name</category><category>nl2br</category><category>numerical datatype</category><category>operator</category><category>optional clauses</category><category>outer joins</category><category>output methods in php</category><category>overview of mysql</category><category>php  regular expressions to compare strings</category><category>php Break and Continue</category><category>php basic</category><category>php comments</category><category>php data types</category><category>php delimiting</category><category>php for statement</category><category>php function</category><category>php introdution</category><category>php user defined function</category><category>php while</category><category>pluggable storage engins</category><category>preg_grep</category><category>preg_match</category><category>preg_match_all</category><category>preg_quote</category><category>preg_replace</category><category>preg_replace_callback</category><category>preg_replace_callback()</category><category>preg_split</category><category>preg_split()</category><category>qualifiers in mysql</category><category>replace</category><category>replacement characters</category><category>replacement procedure</category><category>replacing all occurrences of the pattern searched</category><category>retrieve the last AUTO_INCREMENT value</category><category>reverse  sorting</category><category>reversing HTML special characters back their original string characters</category><category>right outer join</category><category>rtrim</category><category>searching strings using POSIX-style regular expressions</category><category>searching strings using Perl-style regular expressions</category><category>selecting large no of records</category><category>self join</category><category>session</category><category>session.save_handler</category><category>session.save_path</category><category>sort</category><category>split</category><category>split regular expression</category><category>sql</category><category>sql POSIX regular expressions</category><category>sql_regcase</category><category>stack implementation</category><category>str_pad</category><category>str_word_count</category><category>strcasecmp</category><category>strcmp</category><category>strcspn</category><category>strict SQL mode</category><category>string data type</category><category>string expression</category><category>string expression in mysql</category><category>strip_tags</category><category>strspn</category><category>strtolower</category><category>strtoupper</category><category>strtr</category><category>table properties</category><category>tags</category><category>trim</category><category>types of joins</category><category>types of storage medium</category><category>ucfirst</category><category>ucwords</category><category>update in mysql</category><category>update with limit</category><category>uppercase characters to lowercase characters.</category><category>use</category><category>use_cookies</category><category>use_only_cookies</category><category>user defined function</category><category>user defined function in php</category><category>wamp.about wamp</category><category>web tools</category><category>website</category><category>website using php</category><category>what are the column option used in mysql</category><category>what are the data types in mysql</category><category>what are the storage engine used in mysql</category><category>what are the table option in mysql</category><category>what is html</category><category>where clause</category><category>where clause in joins</category><category>while in php</category><title>YOUR WEBSITE</title><description>“The best way to be ready for the future is to invent it.”— John Sculley</description><link>http://urwebsite.blogspot.com/</link><managingEditor>noreply@blogger.com (Anonymous)</managingEditor><generator>Blogger</generator><openSearch:totalResults>139</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><language>en-us</language><itunes:explicit>no</itunes:explicit><itunes:subtitle>“The best way to be ready for the future is to invent it.”— John Sculley</itunes:subtitle><itunes:owner><itunes:email>noreply@blogger.com</itunes:email></itunes:owner><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-7840966247590063229</guid><pubDate>Thu, 23 Aug 2012 11:35:00 +0000</pubDate><atom:updated>2012-08-23T17:05:39.099+05:30</atom:updated><title>Magento Integration: Session Login</title><description>&lt;a href="http://chosencollective.com/technology/magento-integration-session-login#.UDYVWRNt_j4.blogger"&gt;Magento Integration: Session Login&lt;/a&gt;</description><link>http://urwebsite.blogspot.com/2012/08/magento-integration-session-login.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-8265118891889657570</guid><pubDate>Tue, 10 Jul 2012 03:55:00 +0000</pubDate><atom:updated>2012-07-10T09:25:26.762+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Explicit object cloning</category><category domain="http://www.blogger.com/atom/ns#">Final</category><category domain="http://www.blogger.com/atom/ns#">Final  method</category><category domain="http://www.blogger.com/atom/ns#">Final classes</category><category domain="http://www.blogger.com/atom/ns#">instance of operator</category><category domain="http://www.blogger.com/atom/ns#">Interfaces</category><category domain="http://www.blogger.com/atom/ns#">New Object-Oriented Features</category><category domain="http://www.blogger.com/atom/ns#">operator</category><title>New Object-Oriented Features</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
&lt;span style="background-color: white;"&gt;The new OO features are too numerous to give a detailed description in this&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;section. Chapter 3, “PHP 5 OO Language,” details each feature.&lt;/span&gt;&lt;span style="background-color: white;"&gt;The following list provides the main new features:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
public&lt;span style="background-color: white;"&gt;/&lt;/span&gt;&lt;span style="background-color: white;"&gt;private&lt;/span&gt;&lt;span style="background-color: white;"&gt;/&lt;/span&gt;&lt;span style="background-color: white;"&gt;protected&lt;/span&gt;&lt;span style="background-color: white;"&gt;access modifiers for methods and properties.&lt;/span&gt;&lt;span style="background-color: white;"&gt;Allows the use of common OO access modifiers to control access to&lt;/span&gt;&lt;span style="background-color: white;"&gt;methods and properties:&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
class MyClass {&lt;br /&gt;
private $id = 18;&lt;br /&gt;
public function getId() {&lt;br /&gt;
return $this-&amp;gt;id;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unified constructor name&lt;span style="background-color: white;"&gt;__construct()&lt;/span&gt;&lt;span style="background-color: white;"&gt;.&lt;/span&gt;&lt;br /&gt;
Instead of the constructor being the name of the class, it is now declared&amp;nbsp;&lt;span style="background-color: white;"&gt;as&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;__construct()&lt;/span&gt;&lt;span style="background-color: white;"&gt;, which makes it easier to shift classes inside class hierarchies:&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
class MyClass {&lt;br /&gt;
function __construct() {&lt;br /&gt;
print "Inside constructor";&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Object destructor support by defining a&amp;nbsp;&lt;span style="background-color: white;"&gt;__destructor()&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;method.&lt;/span&gt;&lt;span style="background-color: white;"&gt;Allows defining a destructor function that runs when an object&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;is destroyed:&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
class MyClass {&lt;br /&gt;
function __destruct() {&lt;br /&gt;
print ”Destroying object”;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Interfaces.&lt;br /&gt;
&lt;br /&gt;
Gives the ability for a class to fulfill more than one is-a relationships. A class can&amp;nbsp;&lt;span style="background-color: white;"&gt;inherit only from one class, but may implement as many interfaces as it wants:&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
interface Display {&lt;br /&gt;
function display();&lt;br /&gt;
}&lt;br /&gt;
class Circle implements Display {&lt;br /&gt;
function display() {&lt;br /&gt;
print "Displaying circle\n";&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;instance of&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;operator.&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
Language-level support for is-a relationship checking. The PHP 4&amp;nbsp;&lt;span style="background-color: white;"&gt;is_a()&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;function&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;is now deprecated:&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
if ($obj instanceof Circle) {&lt;br /&gt;
print '$obj is a Circle';&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Final methods.&lt;br /&gt;
&lt;br /&gt;
The&amp;nbsp;&lt;span style="background-color: white;"&gt;final&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;keyword allows you to mark methods so that an inheriting class cannot overload&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;them:&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
class MyClass {&lt;br /&gt;
final function getBaseClassName() {&lt;br /&gt;
return __CLASS__;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Final classes.&lt;br /&gt;
&lt;br /&gt;
After declaring a class as&amp;nbsp;&lt;span style="background-color: white;"&gt;final&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;, it cannot be inherited. The following example&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;would error out.&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
final class FinalClass {&lt;br /&gt;
}&lt;br /&gt;
class BogusClass extends FinalClass {&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Explicit object cloning.&lt;br /&gt;
&lt;br /&gt;
To clone an object, you must use the&amp;nbsp;&lt;span style="background-color: white;"&gt;clone&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;keyword. You may declare a&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;__clone()&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;method, which will be called during the clone process (after the properties have&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;been copied from the original object):&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/07/new-object-oriented-features.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-9209969723710526713</guid><pubDate>Mon, 02 Jul 2012 18:15:00 +0000</pubDate><atom:updated>2012-07-02T23:45:39.121+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">array</category><category domain="http://www.blogger.com/atom/ns#">Array Sorting Function</category><category domain="http://www.blogger.com/atom/ns#">arsort</category><category domain="http://www.blogger.com/atom/ns#">attribute sort</category><category domain="http://www.blogger.com/atom/ns#">bool sort</category><category domain="http://www.blogger.com/atom/ns#">how to shuffle array</category><category domain="http://www.blogger.com/atom/ns#">how to sort the key in an array</category><category domain="http://www.blogger.com/atom/ns#">key</category><category domain="http://www.blogger.com/atom/ns#">key sort</category><category domain="http://www.blogger.com/atom/ns#">reverse  sorting</category><category domain="http://www.blogger.com/atom/ns#">sort</category><category domain="http://www.blogger.com/atom/ns#">stack implementation</category><title>Array Sorting Function</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
arsort — Sort an array in reverse order and maintain index association&lt;br /&gt;
asort — Sort an array and maintain index association&lt;br /&gt;
compact — Create array containing variables and their values&lt;br /&gt;
count — Count all elements in an array, or something in an object&lt;br /&gt;
current — Return the current element in an array&lt;br /&gt;
each — Return the current key and value pair from an array and advance the array cursor&lt;br /&gt;
end — Set the internal pointer of an array to its last element&lt;br /&gt;
extract — Import variables into the current symbol table from an array&lt;br /&gt;
in_array — Checks if a value exists in an array&lt;br /&gt;
key — Fetch a key from an array&lt;br /&gt;
krsort — Sort an array by key in reverse order&lt;br /&gt;
ksort — Sort an array by key&lt;br /&gt;
list — Assign variables as if they were an array&lt;br /&gt;
natcasesort — Sort an array using a case insensitive "natural order" algorithm&lt;br /&gt;
natsort — Sort an array using a "natural order" algorithm&lt;br /&gt;
next — Advance the internal array pointer of an array&lt;br /&gt;
pos — Alias of current&lt;br /&gt;
prev — Rewind the internal array pointer&lt;br /&gt;
range — Create an array containing a range of elements&lt;br /&gt;
reset — Set the internal pointer of an array to its first element&lt;br /&gt;
rsort — Sort an array in reverse order&lt;br /&gt;
shuffle — Shuffle an array&lt;br /&gt;
sizeof — Alias of count&lt;br /&gt;
sort — Sort an array&lt;br /&gt;
uasort — Sort an array with a user-defined comparison function and maintain index association&lt;br /&gt;
uksort — Sort an array by keys using a user-defined comparison function&lt;br /&gt;
usort — Sort an array by values using a user-defined comparison function&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://urwebsite.blogspot.com/2012/07/array-sorting-function.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-2953454433470856252</guid><pubDate>Mon, 02 Jul 2012 17:35:00 +0000</pubDate><atom:updated>2012-07-02T23:05:20.152+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">mysql function</category><category domain="http://www.blogger.com/atom/ns#">mysql_connect</category><category domain="http://www.blogger.com/atom/ns#">mysql_create_db</category><category domain="http://www.blogger.com/atom/ns#">mysql_select_db</category><category domain="http://www.blogger.com/atom/ns#">php function</category><category domain="http://www.blogger.com/atom/ns#">PHP MySQL Function</category><title>PHP MySQL Function</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="color: #3d85c6;"&gt;mysql_affected_rows&lt;/span&gt; — Get number of affected rows in previous MySQL operation&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="color: #3d85c6;"&gt;mysql_client_encoding &lt;/span&gt;— Returns the name of the character set&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_close &lt;/span&gt;— Close MySQL connection&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_connect &lt;/span&gt;— Open a connection to a MySQL Server&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_create_db &lt;/span&gt;— Create a MySQL database&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_data_seek &lt;/span&gt;— Move internal result pointer&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_db_name &lt;/span&gt;— Retrieves database name from the call to mysql_list_dbs&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_db_query &lt;/span&gt;— Selects a database and executes a query on it&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_drop_db &lt;/span&gt;— Drop (delete) a MySQL database&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_errno &lt;/span&gt;— Returns the numerical value of the error message from previous MySQL operation&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_error &lt;/span&gt;— Returns the text of the error message from previous MySQL operation&lt;/div&gt;
&lt;div&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="color: #3d85c6;"&gt;mysql_escape_string &lt;/span&gt;&lt;/span&gt;— Escapes a string for use in a mysql_query&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_fetch_array &lt;/span&gt;— Fetch a result row as an associative array, a numeric array, or both&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_fetch_assoc &lt;/span&gt;— Fetch a result row as an associative array&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_fetch_field &lt;/span&gt;— Get column information from a result and return as an object&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_fetch_lengths &lt;/span&gt;— Get the length of each output in a result&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_fetch_object &lt;/span&gt;— Fetch a result row as an object&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_fetch_row &lt;/span&gt;— Get a result row as an enumerated array&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_field_flags &lt;/span&gt;— Get the flags associated with the specified field in a result&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_field_len &lt;/span&gt;— Returns the length of the specified field&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_field_name &lt;/span&gt;— Get the name of the specified field in a result&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_field_seek &lt;/span&gt;— Set result pointer to a specified field offset&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_field_table &lt;/span&gt;— Get name of the table the specified field is in&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_field_type &lt;/span&gt;— Get the type of the specified field in a result&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_free_result &lt;/span&gt;— Free result memory&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_get_client_info &lt;/span&gt;— Get MySQL client info&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_get_host_info &lt;/span&gt;— Get MySQL host info&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_get_proto_info &lt;/span&gt;— Get MySQL protocol info&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_get_server_info &lt;/span&gt;— Get MySQL server info&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_info &lt;/span&gt;— Get information about the most recent query&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_insert_id &lt;/span&gt;— Get the ID generated in the last query&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_list_dbs &lt;/span&gt;— List databases available on a MySQL server&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_list_fields &lt;/span&gt;— List MySQL table fields&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_list_processes &lt;/span&gt;— List MySQL processes&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_list_tables &lt;/span&gt;— List tables in a MySQL database&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_num_fields &lt;/span&gt;— Get number of fields in result&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_num_rows &lt;/span&gt;— Get number of rows in result&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_pconnect &lt;/span&gt;— Open a persistent connection to a MySQL server&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_ping &lt;/span&gt;— Ping a server connection or reconnect if there is no connection&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_query &lt;/span&gt;— Send a MySQL query&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_real_escape_string &lt;/span&gt;— Escapes special characters in a string for use in an SQL statement&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_result &lt;/span&gt;— Get result data&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_select_db &lt;/span&gt;— Select a MySQL database&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_set_charset &lt;/span&gt;— Sets the client character set&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_stat&lt;/span&gt; — Get current system status&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_tablename &lt;/span&gt;— Get table name of field&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_thread_id &lt;/span&gt;— Return the current thread ID&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #3d85c6;"&gt;mysql_unbuffered_query &lt;/span&gt;— Send an SQL query to MySQL without fetching and buffering the result rows.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/07/php-mysql-function.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-6891657041621285795</guid><pubDate>Mon, 25 Jun 2012 04:41:00 +0000</pubDate><atom:updated>2012-06-27T14:09:53.670+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">create</category><category domain="http://www.blogger.com/atom/ns#">from</category><category domain="http://www.blogger.com/atom/ns#">join</category><category domain="http://www.blogger.com/atom/ns#">joins</category><category domain="http://www.blogger.com/atom/ns#">left join</category><category domain="http://www.blogger.com/atom/ns#">right join</category><category domain="http://www.blogger.com/atom/ns#">SQL JOINS</category><category domain="http://www.blogger.com/atom/ns#">update</category><category domain="http://www.blogger.com/atom/ns#">WHERE</category><title>SQL Joins</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
1. Login in to the mysql client using the login name and password provided by your instructor (if&lt;br /&gt;
not already logged in).&lt;br /&gt;
&lt;br /&gt;
2. View the existing databases that the MySQL Server is maintaining.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SHOW DATABASES;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
3. Utilize the photo_album database.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;USE photo_album;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
---- If Need be, recreate the database and load the SQL data&lt;br /&gt;
in that will be used for this lab&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;CREATE DATABASE photo_album;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SOURCE /tmp/photo_album.sql;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
4. Query the database to display the active primary customer (email, first and last name) and all&lt;br /&gt;
the associated active login names associated with that customer.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SELECT customers.email_customer, customers.fname,&lt;span style="background-color: white;"&gt;customers.lname, logins.login_name&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;FROM customers, logins&lt;/span&gt;&lt;span style="background-color: white;"&gt;WHERE customers.email_customer = logins.email_customer&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;AND customers.active_customer = 'True'&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;AND logins.active_login = 'True';&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
5. Modify the query just issued to also show the image name of all the active files associated with&lt;br /&gt;
each one of the login names.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SELECT customers.email_customer, customers.fname,&lt;span style="background-color: white;"&gt;customers.lname, logins.login_name,images.file_name&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;FROM customers, logins, images&amp;nbsp;&lt;span style="background-color: white;"&gt;WHERE customers.email_customer = logins.email_customer&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;AND logins.login_name =images.login_name&amp;nbsp;&lt;span style="background-color: white;"&gt;AND customers.active_customer = 'True'&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;AND logins.active_login = 'True'&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;AND images.active_image = 'True';&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
6. The customer with the login name of Frankie has requested that his login name be changed to&lt;br /&gt;
just 'Frank' to make it easier for him to remember it. The only problem is that the change must&lt;br /&gt;
also take place in the images table. This is not automatic due to the fact that this table is a&lt;br /&gt;
MyISAM table (rightfully so) and there is no Foreign Key constraints that would make the&lt;br /&gt;
change automatic. However, this is not a problem with the right update statement against the&lt;br /&gt;
two tables at once. Can you make one query that will update both the tables at once?&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;UPDATE logins, images, comments&amp;nbsp;&lt;span style="background-color: white;"&gt;SET logins.login_name = 'Frank',&lt;/span&gt;&lt;span style="background-color: white;"&gt;images.login_name = 'Frank'&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;WHERE logins.login_name = images.login_name&amp;nbsp;&lt;span style="background-color: white;"&gt;AND logins.login_name = 'Frankie';&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/sql-joins.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-5625954051579021377</guid><pubDate>Sat, 23 Jun 2012 03:46:00 +0000</pubDate><atom:updated>2012-06-23T09:16:00.430+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">database</category><category domain="http://www.blogger.com/atom/ns#">db</category><category domain="http://www.blogger.com/atom/ns#">ddl</category><category domain="http://www.blogger.com/atom/ns#">dml</category><category domain="http://www.blogger.com/atom/ns#">from</category><category domain="http://www.blogger.com/atom/ns#">SELECT</category><category domain="http://www.blogger.com/atom/ns#">show</category><category domain="http://www.blogger.com/atom/ns#">SQL DML Commands</category><category domain="http://www.blogger.com/atom/ns#">WHERE</category><title>SQL DML Commands</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
1. Login in to the mysql client using the login name and password provided by your instructor (if&lt;br /&gt;
not already logged in).&lt;br /&gt;
&lt;br /&gt;
2. View the existing databases that the MySQL Server is maintaining.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SHOW DATABASES;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
3. Utilize the photo_album database.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;USE photo_album;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;---- If Need be, recreate the database and load the SQL data&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;in that will be used for this lab&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="color: #3d85c6;"&gt;CREATE DATABASE photo_album;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SOURCE /tmp/photo_album.sql;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
4. Search the customers records for the customer with the following e-mail address:&lt;br /&gt;
hollywood@truedog.com&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SELECT * FROM customers WHERE email_customer =&lt;span style="background-color: white;"&gt;'hollywood@truedog.com'\G&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
5. Search the logins records for logins associated with the customer identified in step 4.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SELECT * FROM logins WHERE email_customer =&lt;span style="background-color: white;"&gt;'hollywood@truedog.com';&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
6. In the customers table, update the customers e-mail address, identified in step 4, to&lt;br /&gt;
howleewood@truedog.com.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;UPDATE customers SET email_customer = 'howleewood@truedog.com'&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;WHERE email_customer = 'hollywood@truedog.com';&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
7. Review the customers records to see if the change (from step 6) took place. If the update did&lt;br /&gt;
not take place, reissue the statement in step 6 to ensure the change takes place?&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SELECT * FROM customers WHERE email_customer =&lt;span style="background-color: white;"&gt;'howleewood@truedog.com'\G&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
8. Review the logins table to see if the e-mails associated with the customer in step 6 were also&lt;br /&gt;
changed. If the e-mail associated with that customer were also changed in the logins table,&lt;br /&gt;
why?&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SELECT * FROM logins WHERE email_customer =&lt;span style="background-color: white;"&gt;'howleewood@truedog.com'\G&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/sql-dml-commands.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-435948864605999323</guid><pubDate>Thu, 21 Jun 2012 12:27:00 +0000</pubDate><atom:updated>2012-06-21T17:57:59.094+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">create</category><category domain="http://www.blogger.com/atom/ns#">from</category><category domain="http://www.blogger.com/atom/ns#">if</category><category domain="http://www.blogger.com/atom/ns#">in</category><category domain="http://www.blogger.com/atom/ns#">overview of mysql</category><category domain="http://www.blogger.com/atom/ns#">SELECT</category><category domain="http://www.blogger.com/atom/ns#">SQL Expressions</category><category domain="http://www.blogger.com/atom/ns#">WHERE</category><title>SQL Expressions</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
1. Login in to the mysql client using the login name and password provided by your instructor (if&lt;br /&gt;
not already logged in).&lt;br /&gt;
&lt;br /&gt;
2. View the existing databases that the MySQL Server is maintaining.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: red;"&gt;SHOW DATABASES;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
3. Utilize the photo_album database.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: red;"&gt;USE photo_album;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
---- If Need be, recreate the database and load the SQL data in that will be used for this lab&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: red;"&gt;CREATE DATABASE photo_album;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="color: red;"&gt;SOURCE /tmp/photo_album.sql;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
4. Calculate how many days ago each person logged into the photo_album system. Note:&lt;br /&gt;
Difference in dates are returned in microseconds when directly subtracted from each other.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: red;"&gt;SELECT login_name, ROUND((NOW() - last_login)/24/60/60/60)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;FROM logins;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
5. List the actual day name (Monday, Tuesday, etc.) for the last logins to determine if there is a&lt;br /&gt;
trend in the day of the week for the last time a person logged into the photo_album system.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: red;"&gt;SELECT login_name, DAYNAME(last_login) FROM logins;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
6. Modify the statement above by having the output show 'Weekend' for Saturday and Sunday, and&lt;br /&gt;
'Weekday' for every other day.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: red;"&gt;SELECT login_name, IF(DAYNAME(last_login)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;IN('Saturday','Sunday'),'Weekend','Weekday') FROM logins;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
7. Show the expiration dates (term_date) for the customers with the first name Granny and&lt;br /&gt;
Yogi, without using two where statements.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: red;"&gt;SELECT f_name, term_date from customers WHERE fname&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;IN('Granny','Yogi');&lt;/span&gt;&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/sql-expressions.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-9149013040720114620</guid><pubDate>Wed, 20 Jun 2012 03:56:00 +0000</pubDate><atom:updated>2012-06-20T09:26:16.910+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Selecting a Database</category><category domain="http://www.blogger.com/atom/ns#">selecting large no of records</category><category domain="http://www.blogger.com/atom/ns#">SQL SELECT Commands</category><title>SQL SELECT Commands</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
1. Login in to the mysql client using the login name and password provided by your instructor (if&lt;br /&gt;
not already logged in).&lt;br /&gt;
&lt;br /&gt;
2. In the photo_album databases, load the /tmp/photo_album.sql.data file into the&lt;br /&gt;
database.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;USE photo_album;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SOURCE /tmp/photo_album.sql;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
3. Perform an aggregate select against each table to count the number of records located in each&lt;br /&gt;
table.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SELECT COUNT(*) FROM customers;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SELECT COUNT(*) FROM comments;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SELECT COUNT(*) FROM images;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SELECT COUNT(*) FROM logins;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
4. Using the customers table, list the customers who are active from closest to farthest&lt;br /&gt;
termination date (term_date).&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SELECT * FROM customers WHERE active_customer='True' ORDER BY&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;term_date ASC;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
5. Using the logins table, list those with active logins and have logged in during the month of&lt;br /&gt;
April 2007.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SELECT * FROM logins WHERE active_login='True' &amp;amp;&amp;amp; last_login&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;LIKE '2007-04%';&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
6. Using the images table, list the active images names from the most recent date to the oldest&lt;br /&gt;
dates (image_date).&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SELECT file_name, image_date FROM images WHERE active_image&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;ORDER BY image_date DESC;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
7. Using the comments table, list the user with the most active comments.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SELECT login_name, COUNT(*) FROM comments WHERE active_comment =&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;'True' GROUP BY login_name DESC;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/sql-select-commands.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-619302869842222376</guid><pubDate>Wed, 20 Jun 2012 03:54:00 +0000</pubDate><atom:updated>2012-06-20T09:24:06.393+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">create table</category><category domain="http://www.blogger.com/atom/ns#">how to create a database in mysql</category><category domain="http://www.blogger.com/atom/ns#">Managing Database Tables</category><category domain="http://www.blogger.com/atom/ns#">show</category><category domain="http://www.blogger.com/atom/ns#">use</category><title>Managing Database Tables</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
1. Login in to the mysql client using the login name and password provided by your instructor.&lt;br /&gt;
&lt;br /&gt;
2. View the existing databases that the MySQL Server is maintaining.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SHOW DATABASES;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
3. Utilize the photo_album database.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;USE photo_album;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
4. Create the first table called customers that will store the information related to the customers&lt;br /&gt;
who have purchased access to the online photo album&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;CREATE TABLE customers (&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;email_customer VARCHAR(50) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;f_name VARCHAR(20) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;l_name VARCHAR(30) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;addr1 VARCHAR(30) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;addr2 VARCHAR(30) NULL,&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;addr_city VARCHAR(25) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;addr_state CHAR(3) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;addr_zip CHAR(10) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;primary_phone CHAR(12) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;secondary_phone CHAR(12) NULL,&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;term_date DATE NOT NULL DEFAULT 0,&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;active_customer ENUM('True', 'False') NOT NULL DEFAULT&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;'True',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;PRIMARY KEY (email_customer)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;) ENGINE=INNODB;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Create the second table called logins that will contain the login authentication data. Each&lt;br /&gt;
customer will be able to have up to 5 logins for their site (this could be given to family and&lt;br /&gt;
friends to access their photos).&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;CREATE TABLE logins (&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;login_name VARCHAR(30) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;email_customer VARCHAR(50) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;f_name VARCHAR(20) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;l_name VARCHAR(30) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;passwd VARCHAR(30) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;last_login DATETIME NOT NULL DEFAULT 0,&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;active_login ENUM('True', 'False') NOT NULL DEFAULT 'True',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;PRIMARY KEY (login_name),&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;INDEX (email_customer),&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;FOREIGN KEY (email_customer)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;REFERENCES customers (email_customer)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;ON UPDATE CASCADE&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;) ENGINE=INNODB;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
---- Note: The reason we do not want a DELETE CASCADE on this FK relationship is due to the&lt;br /&gt;
fact that we do not want to lose the customer information. By setting the active_customer to&lt;br /&gt;
False, we can simply code a response to the customer when they attempt to log in that there&lt;br /&gt;
account has been closed. If they wish to pay us, we will be happy to open their account again and&lt;br /&gt;
they have lost nothing. However, a policy would have to be in place on when data is archived.&lt;br /&gt;
&lt;br /&gt;
6. Create the third table called images that will contain the information about the photos. The&lt;br /&gt;
image information will include information to connect the images to other tables, the size of the&lt;br /&gt;
image and the name of the image that was stored. Later in the course, the code will be created&lt;br /&gt;
to upload these images with the image information being stored in the database.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;CREATE TABLE images (&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;id_image INT UNSIGNED AUTO_INCREMENT NOT NULL,&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;login_name VARCHAR(30) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;image_size VARCHAR(30) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;file_name VARCHAR(60) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;image_date DATE NOT NULL DEFAULT 0,&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;active_image ENUM('True', 'False') NOT NULL DEFAULT 'True',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;PRIMARY KEY (id_image),&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;INDEX (login_name)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;) ENGINE=MYISAM;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
7. Create the last table called comments that will be used to keep track of the comments attached&lt;br /&gt;
to each picture. Each login associated with the images will be able to provide comments against&lt;br /&gt;
the picture.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;CREATE TABLE comments (&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;id_comment INT UNSIGNED AUTO_INCREMENT NOT NULL,&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;login_name VARCHAR(30) NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;id_image INT UNSIGNED NOT NULL DEFAULT 0,&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;comments TEXT NOT NULL DEFAULT '',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;log_date TIMESTAMP NOT NULL,&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;active_comment ENUM('True', 'False') NOT NULL DEFAULT 'True',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;PRIMARY KEY (id_comment),&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;INDEX (id_image)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;) ENGINE=MYISAM;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;8. View the list of tables located in the photo_album database.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SHOW TABLES;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
9. Review the details of each table created and verify that the tables were designed properly. If&lt;br /&gt;
they are not correct, use the ALTER TABLE command to make the changes to correct the&lt;br /&gt;
problems.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SHOW CREATE TABLE customers\G&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SHOW CREATE TABLE logins\G&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SHOW CREATE TABLE images\G&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;SHOW CREATE TABLE comments\G&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/managing-database-tables.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-1492738604038046654</guid><pubDate>Sun, 17 Jun 2012 12:56:00 +0000</pubDate><atom:updated>2012-06-17T18:26:06.826+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">how to manage a database</category><category domain="http://www.blogger.com/atom/ns#">Managing Databases</category><title>Managing Databases</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
1. Login in to the mysql client using the login name and password provided by your instructor.&lt;br /&gt;
&lt;br /&gt;
2. View the existing databases that the MySQL Server is maintaining.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; SHOW DATABASES;&lt;br /&gt;
&lt;br /&gt;
3. There should be only three databases that the MySQL Server is maintaining:&lt;br /&gt;
INFORMATION_SCHEMA, mysql and test. Remove any additional databases that exist.&lt;br /&gt;
&lt;br /&gt;
If need be, mysql&amp;gt; DROP DATABASE db_name;&lt;br /&gt;
&lt;br /&gt;
4. Create a new database called photo_album with a default character set of utf8.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; CREATE DATABASE photo_album CHARACTER SET utf8;&lt;br /&gt;
&lt;br /&gt;
5. Using the mysql client, verify that the database was created.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; SHOW DATABASES;&lt;br /&gt;
&lt;br /&gt;
6. View the contents of the /usr/local/mysql/data directory. Is there a new sub-directory associated with&lt;br /&gt;
the database just created?&lt;br /&gt;
&lt;br /&gt;
&amp;gt;ls /usr/local/mysql/data/&lt;br /&gt;
&lt;br /&gt;
7. View the db.opt file located in the associated sub-directory to verify the correct default character set&lt;br /&gt;
is being used. What collation type has been assigned as default? Does that make sense for the&lt;br /&gt;
character set chosen?&lt;br /&gt;
&lt;br /&gt;
&amp;gt; more /usr/local/mysql/data/photo_album/db.opt&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/managing-databases.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-6250765782545729671</guid><pubDate>Sat, 16 Jun 2012 07:19:00 +0000</pubDate><atom:updated>2012-06-16T12:49:31.379+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">count_chars</category><category domain="http://www.blogger.com/atom/ns#">Counting Strings</category><category domain="http://www.blogger.com/atom/ns#">PHP's regular expressions</category><category domain="http://www.blogger.com/atom/ns#">REGULAR EXPRESSIONS</category><category domain="http://www.blogger.com/atom/ns#">str_word_count</category><title>Counting Strings</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
Due to the fact that PHP's regular expressions are so versatile, many functions that have been designed by&lt;br /&gt;
PHP developers have been overlooked in the past because the tasks were able to be completed with regular&lt;br /&gt;
expressions. However, there are two functions that should not be overlooked due to their simplicity in&lt;br /&gt;
performing a more complex task.&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;count_chars &lt;/span&gt;-&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;This built-in function provides information about the number of times that an standard&lt;br /&gt;
ASCII character appears in the string.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "I went to Mississippi for the summer.";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$letters = count_chars($text, 1);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// 1 counts only the characters that show up more than zero&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;times&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// 0 is the default and produces the entire listing of standard&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// ASCII characters, even those not showing up in the string&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// 2 returns only those ASCII characters that do not show up&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// 3 &amp;amp; 4 return byte info (all located and all unused,&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;respectively)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;foreach($letters as $key=&amp;gt;$value) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print chr($key)." = ".$value;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// A list of characters followed by their frequency appears&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// The order is based on the standard ASCII order&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: red;"&gt;str_word_count &lt;/span&gt;-&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;This built-in function works on a similar principal to the count_chars() function,&lt;br /&gt;
but with the focus on the words themselves versus the characters. The basic function is to return a&lt;br /&gt;
numeric count of the number of words contained in the string.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "I went to Mississippi for the summer.";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print str_word_count($text); // Returns the number of words&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;found&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Another way the function works is by placing each word in the string into an array. This array can be&lt;br /&gt;
built one of two ways. By placing a numeric 1 in the second parameter option, the array will be built&lt;br /&gt;
with just the words as the entities for the array. By placing a numeric 2 in the second parameter&lt;br /&gt;
option, the array will be built with the entities built with the key being the numeric location of where&lt;br /&gt;
the word was located in the array and the value of the word as the key.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;$text = "I went to Mississippi for the summer.";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;$words = str_word_count($text,1);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;print_r($words,1);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;// The following will be "printed" out:&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;// Array ( [0] =&amp;gt; I [1] =&amp;gt; went [2] =&amp;gt; to [3] =&amp;gt; Mississippi&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;// [4] =&amp;gt; for [5] =&amp;gt; the [6] =&amp;gt; summer )&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;$text = "I went to Mississippi for the summer.";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;$words = str_word_count($text,2);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;print_r($words,1);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;// The following will be "printed" out:&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;// Array ( [0] =&amp;gt; I [2] =&amp;gt; went [7] =&amp;gt; to [10] =&amp;gt; Mississippi&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;// [22] =&amp;gt; for [26] =&amp;gt; the [30] =&amp;gt; summer )&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0b5394;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/counting-strings.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-1322885534329162070</guid><pubDate>Sat, 16 Jun 2012 04:41:00 +0000</pubDate><atom:updated>2012-06-16T10:11:09.216+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">ltrim</category><category domain="http://www.blogger.com/atom/ns#">Modify String Length</category><category domain="http://www.blogger.com/atom/ns#">rtrim</category><category domain="http://www.blogger.com/atom/ns#">str_pad</category><category domain="http://www.blogger.com/atom/ns#">trim</category><title>Modify String Length</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
When performing the duties of creating/manipulating web content, the PHP programmer will need to&lt;br /&gt;
modify the lengths of strings, either by padding the strings to be a certain length or removing strings to be a&lt;br /&gt;
certain length. PHP provides numerous built-in functions to accomplish these tasks. The following are the&lt;br /&gt;
most common functions for modifying string lengths:&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;ltrim &lt;/span&gt;-&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;The name of this function identifies its purpose, to trim the string content starting from the&lt;br /&gt;
left portion of the string. By default, the ltrim() function will remove all white space characters which&lt;br /&gt;
includes the standard space, the horizontal tab(\t), vertical tab (\x0b), new line (\n), carriage return (\r)&lt;br /&gt;
and NULL (\0). This function will continue to remove these characters until it reaches a non-white&lt;br /&gt;
space character and then the function removal process will terminate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = \n\t Jane wanted to listen to the troupe play.";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print ltrim($text);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// The new text printed will be "Jane wanted to listen to the&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// troupe play."&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If there are other characters that must be removed from the left portion of the string, they can be&lt;br /&gt;
placed into the second component of the function which is the optional parameter option. When there&lt;br /&gt;
is a value in the optional parameter option, all other characters will remain (even white space&lt;br /&gt;
characters). If the programmer requires white space characters to be removed also, they must enter&lt;br /&gt;
them into the optional parameter option along with the additional required character. With the&lt;br /&gt;
optional parameter option, the function will also continue to remove characters until it finds a&lt;br /&gt;
character that is not in the optional parameter list and then terminate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "\ta) \n\tJane wanted to listen to the troupe play.";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print ltrim($text, "\ta) ");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// The new text printed will be "\n\tJane wanted to listen to&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;the&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// troupe play."&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;rtrim &lt;/span&gt;-&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Is equivalent to the ltrim() function in how it performs, the only difference is it trims from the&lt;br /&gt;
end of the string versus the beginning of the string.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$text = "Jane wanted to listen to the troupe play. \n";&lt;br /&gt;
print ltrim($text);&lt;br /&gt;
// The new text printed will be "Jane wanted to listen to the&lt;br /&gt;
// troupe play." Without the space and line return at the end&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;trim &lt;/span&gt;-&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Is equivalent to the ltrim() and rtrim() functions combined together. The trim() function&lt;br /&gt;
trims the characters from the beginning of the string and the end of the string.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "\n Jane wanted to listen to the troupe play. \n";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print ltrim($text);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// The new text printed will be "Jane wanted to listen to the&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// troupe play." Without the space and line return on either end&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;str_pad &lt;/span&gt;-&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;This function will insert characters (spaces by default) into a string to force the string to be&lt;br /&gt;
a certain length (which is defined in the second parameter of the function).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "Title";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print str_pad($text, 15);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// The new text printed will be "Title "&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
A PHP programmer can also change the default character (a space) to another character(s) by placing&lt;br /&gt;
the character(s) into the third optional parameter option.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "Title";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print str_pad($text, 15, "-|");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// The new text printed will be "Title-|-|-|-|-|"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
By default the padding is added to the end of the string; however, by entering either&lt;br /&gt;
STR_PAD_RIGHT, STR_PAD_LEFT or STR_PAD_BOTH into the fourth optional parameter&lt;br /&gt;
option, the programmer can control where the padding will be added. When using the fourth optional&lt;br /&gt;
parameter option, the third optional parameter option must also have a character (even if it just a&lt;br /&gt;
space).&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "Title";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print str_pad($text, 15, " ", STR_PAD_BOTH);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// The new text printed will be " Title "&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/modify-string-length.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-3270292611506539939</guid><pubDate>Wed, 13 Jun 2012 04:16:00 +0000</pubDate><atom:updated>2012-06-13T09:46:00.219+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">array_flip</category><category domain="http://www.blogger.com/atom/ns#">HTML to Text Conversion Functions</category><category domain="http://www.blogger.com/atom/ns#">reversing HTML special characters back their original string characters</category><category domain="http://www.blogger.com/atom/ns#">strip_tags</category><title>HTML to Text Conversion Functions</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;array_flip &lt;/span&gt;-&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; This function is the opposite function for the get_html_translation_table() function by&lt;br /&gt;
reversing HTML special characters back their original string characters.&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$html_text = "J&amp;amp;uacute;an and Fel&amp;amp;iacute;pe paid 13&amp;amp;cent; a&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;piece&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;for gum."&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$translation_table = get_html_translation_table(HTML_ENTITIES);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$flipped = array_flip($translation_table);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print strtr($html_text, $flipped);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// The sentence will now read "Júan and Felípe paid 13¢ a piece&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;for&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// gum" without any HTML translation&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
• &lt;span style="color: red;"&gt;strip_tags&lt;/span&gt;() -&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;This function removes all HTML and PHP tags from a string.&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$html_text = "&amp;lt;a href=\"http://www.johnsgifts.com\"&amp;gt;&amp;lt;strong&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;John's Gifts&amp;lt;/strong&amp;gt;&amp;lt;/a&amp;gt;";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print strip_tags($html_text);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// Returns John's Gifts with no HTML tags&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
In the even that a tag type should remain while all others are removed, that can be accomplished by&lt;br /&gt;
adding the HTML tag in the optional second component of the function.&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$html_text = "&amp;lt;a href=\"http://www.johnsgifts.com\"&amp;gt;&amp;lt;strong&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;John's Gifts&amp;lt;/strong&amp;gt;&amp;lt;/a&amp;gt;";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print strip_tags($html_text, "&amp;lt;strong&amp;gt;");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// Returns &amp;lt;strong&amp;gt;John's Gifts&amp;lt;/strong&amp;gt; but without the &amp;lt;a&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;tags&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/html-to-text-conversion-functions.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-8997589764607059615</guid><pubDate>Wed, 13 Jun 2012 04:09:00 +0000</pubDate><atom:updated>2012-06-13T09:39:00.432+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">acronym for  newline to br tags special characters in HTML to their HTML equivalents</category><category domain="http://www.blogger.com/atom/ns#">get_html_translation_table</category><category domain="http://www.blogger.com/atom/ns#">HTML Conversion</category><category domain="http://www.blogger.com/atom/ns#">htmlspecialchars</category><category domain="http://www.blogger.com/atom/ns#">nl2br</category><category domain="http://www.blogger.com/atom/ns#">strtr</category><title>HTML Conversion</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
&lt;br /&gt;
PHP's strength is in its ability to turn a static web page into a dynamic web page by interacting directly with&lt;br /&gt;
the HTML. Part of this strength is PHP's ability to convert non-HTML (text only) strings to HTML and&lt;br /&gt;
HTML strings to non-HTML strings. To make this happen, PHP provides multiple built-in functions&lt;br /&gt;
designed specifically for HTML conversions. The following is a list of the most commonly used:&lt;br /&gt;
Text to HTML Conversion Functions&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;nl2br &lt;/span&gt;-&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; This function name (nl2br) is an acronym for "newline to &amp;lt;br /&amp;gt; tags" due to the fact that this&lt;br /&gt;
function will convert all newline characters (\n) in strings to their XHTML-compliant equivalent (&amp;lt;br&lt;br /&gt;
/&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "See Spot.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;See Spot run.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;See Spot fall.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;See Spot's friends laugh.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;Hear Spot growl.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;See Spot's friends run.";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print nl2br($text);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// The sentence will now read "See Spot.&amp;lt;br /&amp;gt;See Spot run.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// &amp;lt;br /&amp;gt;See Spot fall.&amp;lt;br /&amp;gt;See Spot's friends laugh.&amp;lt;br /&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// Hear Spot growl.&amp;lt;br /&amp;gt;See Spot's friends run."&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;htmlspecialchars &lt;/span&gt;- &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;There are numerous characters that HTML identifies as special for completing&lt;br /&gt;
certain tasks that are everyday characters in written language. For example; the ampersand sign (&amp;amp;)&lt;br /&gt;
is used in many languages to abbreviate the word "and"; however, the ampersand sign is also used in&lt;br /&gt;
HTML as a special character. If a programmer wants to actually use the ampersand sign as its&lt;br /&gt;
original meaning, the following HTML code must be entered in its place: "&amp;amp;amp" as in "Jack &amp;amp;amp&lt;br /&gt;
Jill". The PHP function htmlspecialchars() will convert all such special characters in HTML to their&lt;br /&gt;
HTML equivalents.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text="&amp;lt;&amp;lt;Storytime&amp;gt;&amp;gt; Jack &amp;amp; Jill went up the hill ... Jack&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;fell&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;down! Jill screamed \"Jack are you OK?\"";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print htmlspecialchars($text);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// The sentence will now read "&amp;amp;lt;&amp;amp;lt;Storytime&amp;amp;gt;&amp;amp;gt; Jack&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// &amp;amp;amp Jill went up the hill ... Jack fell down! Jill&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;screamed&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// &amp;amp;quot;Jack are you OK?&amp;amp;quot;"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
If using both the nl2br() and htmlspecialchars() functions against the same string, it is important to&lt;br /&gt;
execute the htmlspecialchars() first and then nl2br() second. If the order is reversed, the XHTMLequivalent&lt;br /&gt;
line returns (&amp;lt;br /&amp;gt;) will be converted to &amp;amp;lt;br /&amp;amp;gt; defeating the purpose of the&lt;br /&gt;
functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;strtr &lt;/span&gt;-&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;This function uses arrays to handle search and replace operations. It is similar in nature to the&lt;br /&gt;
preg_replace() Perl-style regular expression function. The following is an example presented earlier&lt;br /&gt;
using the preg_replace() function:&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "The dog barks, the bear growls and the cat meows";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$adults = array("/dog/", "/bear/", "/cat/");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$children = array("puppy", "cub", "kitten");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print preg_replace($adults,$children, $text);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The following is an example of using the strtr() function to recreate the above example:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "The dog barks, the bear growls and the cat meows";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$translation_table = array("dog" =&amp;gt; "puppy", "bear" =&amp;gt; "cub",&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;"cat" =&amp;gt; "kitten");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print strtr($text, $translation_table);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
With this capability, there are many uses that the strtr() function can provide to the programmer.&lt;br /&gt;
However, due to the fact that the discussion now revolves around converting strings to HTML, it is&lt;br /&gt;
time to talk about the get_html_translation_table() function.&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;get_html_translation_table &lt;/span&gt;-&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PHP has built in arrays for handling the most common HTML&lt;br /&gt;
equivalent characters. The arrays are referenced by calling them with the function&lt;br /&gt;
get_html_translation_table(). The two arrays that are available are HTML_SPECIALCHARS and&lt;br /&gt;
HTML_ENTITIES. The following examples demonstrate how these two arrays are called and&lt;br /&gt;
utilized in PHP code:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text="&amp;lt;&amp;lt;Storytime&amp;gt;&amp;gt; Jack &amp;amp; Jill went up the hill ... Jack fell&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;down! Jill screamed \"Jack are you OK?\"";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$translation_table=get_html_translation_table(HTML_SPECIALCHARS);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print strtr($text, $translation_table);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// The sentence will now read "&amp;amp;lt;&amp;amp;lt;Storytime&amp;amp;gt;&amp;amp;gt; Jack&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// &amp;amp;amp Jill went up the hill ... Jack fell down! Jill screamed&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// &amp;amp;quot;Jack are you OK?&amp;amp;quot;"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text="Júan and Felípe paid 13¢ a piece for gum.";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$translation_table = get_html_translation_table(HTML_ENTITIES);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print strtr($text, $translation_table);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// The sentence will now read "J&amp;amp;uacute;an and Fel&amp;amp;iacute;pe&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;//paid 13&amp;amp;cent; a piece for gum."&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
To see what characters are in the HTML_ENTITIES translation tables, use the following PHP code&lt;br /&gt;
(view the source of the web page to see the HTML special characters):&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$translation_table = get_html_translation_table(HTML_ENTITIES);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;foreach($translation_table as $row) print "$row&amp;lt;br&amp;gt;\n";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/html-conversion.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-9173159096938830996</guid><pubDate>Tue, 12 Jun 2012 05:30:00 +0000</pubDate><atom:updated>2012-06-12T09:35:43.649+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">first character of each word in the string to uppercase</category><category domain="http://www.blogger.com/atom/ns#">Manipulating String Cases</category><category domain="http://www.blogger.com/atom/ns#">strtolower</category><category domain="http://www.blogger.com/atom/ns#">strtoupper</category><category domain="http://www.blogger.com/atom/ns#">ucfirst</category><category domain="http://www.blogger.com/atom/ns#">ucwords</category><category domain="http://www.blogger.com/atom/ns#">uppercase characters to lowercase characters.</category><title>Manipulating String Cases</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
&lt;br /&gt;
Case sensitivity is an issue that the programmer (and the end user) must deal with. Everything from&lt;br /&gt;
commands to passwords are affected by case sensitivity. In PHP there are four functions that provide the&lt;br /&gt;
tools to deal with the case sensitivity issue by allowing the string case to be manipulated.&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;strtolower &lt;/span&gt;-&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;This string case manipulation function converts all characters that are uppercase&lt;br /&gt;
characters to lowercase characters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "MySQL http://WWW.MYSQL.COM";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print strtolower($text);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// Returns "mysql http://www.mysql.com";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;strtoupper&lt;/span&gt; -&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;This string case manipulation function converts all characters that are lowercase&lt;br /&gt;
characters to uppercase characters.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "MySQL http://WWW.MYSQL.COM";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print strtoupper($text);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// Returns "MYSQL HTTP://WWW.MYSQL.COM";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;ucfirst &lt;/span&gt;-&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; This string case manipulation function converts only the first character of the string to&lt;br /&gt;
uppercase. The remaining characters are left alone.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "mysql http://www.MySQL.com";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print ucfirst($text);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// Returns "Mysql http://www.MySQL.com ";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;ucwords &lt;/span&gt;-&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;This string case manipulation function converts the first character of each word in the&lt;br /&gt;
string to uppercase. The remaining characters in each word are left alone.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "my mother said to pick the very best one and ...";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print ucwords($text);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// Returns "My Mother Said To Pick The Very Best One And ...";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/manipulating-string-cases.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-8703565653037608446</guid><pubDate>Tue, 12 Jun 2012 04:53:00 +0000</pubDate><atom:updated>2012-06-12T10:23:00.727+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Comparison Functions</category><category domain="http://www.blogger.com/atom/ns#">Other String Comparison Functions</category><category domain="http://www.blogger.com/atom/ns#">strcasecmp</category><category domain="http://www.blogger.com/atom/ns#">strcspn</category><category domain="http://www.blogger.com/atom/ns#">String Comparison Functions</category><category domain="http://www.blogger.com/atom/ns#">strspn</category><title>Other String Comparison Functions</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
&lt;br /&gt;
While the strcmp() function is the most commonly used string comparison function in PHP, there are other&lt;br /&gt;
string comparison functions offered:&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;strcasecmp&lt;/span&gt; -&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;This string comparison function is equivalent to the strcmp() function except that it is&lt;br /&gt;
not case sensitive.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;function chk_emails($input1, $input2) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;if (! strcasecomp($input1, $input2)) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print "E-mails are the same, proceed&amp;lt;br&amp;gt;";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}else {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print "E-mails are not equal&amp;lt;br&amp;gt;";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;chk_emails("jones@mysql.com","Jones@MySQL.com");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// strcasecmp is case-insensitive and thus these two e-mails&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// are the same&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
• &lt;span style="color: red;"&gt;strspn&lt;/span&gt; -&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; The strspn() function compares two strings to determine how closely related they are to each&lt;br /&gt;
other. This is accomplished by returning the length of the first string containing characters that are&lt;br /&gt;
also located in the second string.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;function passwd_diff($n_passwd, $o_passwd) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;if (strspn($n_passwd, $o_passwd) &amp;gt; (strlen($o_passwd) *.75))&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print "New password must be noticeably different from&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;the old password&amp;lt;br&amp;gt;";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}else {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print "The new password is acceptable&amp;lt;br&amp;gt;";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;passwd_diff ("mydogskip","mydogskippy");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// The characters in the new password and old password are&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style="color: #3d85c6;"&gt;
// too similar to be allowed&lt;/div&gt;
&lt;div style="color: #3d85c6;"&gt;
passwd_diff ("myfriendskip","mydogskippy");&lt;/div&gt;
&lt;div style="color: #3d85c6;"&gt;
// The characters are different enough between the two&lt;/div&gt;
&lt;div style="color: #3d85c6;"&gt;
// passwords to be considered acceptable&lt;/div&gt;
&lt;div style="color: #3d85c6;"&gt;
?&amp;gt;&lt;/div&gt;
&lt;div style="color: #3d85c6;"&gt;
&lt;br /&gt;&lt;/div&gt;
• &lt;span style="color: red;"&gt;strcspn&lt;/span&gt; -&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;The strcspn() function is similar to the strspn() function in that it compares two strings to&lt;br /&gt;
determine how closely related they are to each other. However, rather than giving a number related to&lt;br /&gt;
the similarities it looks at each character from left to right and identifies the first segment in the first&lt;br /&gt;
string containing characters not in the second string.&lt;br /&gt;
&lt;div style="color: #3d85c6;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="color: #3d85c6;"&gt;
&amp;lt;?php&lt;/div&gt;
&lt;div style="color: #3d85c6;"&gt;
$alphabet1 = "abcdefghijklmnopqrstuvwxyz";&lt;/div&gt;
&lt;div style="color: #3d85c6;"&gt;
$alphabet2 = "ghijklmnopqrstuvwxyz";&lt;/div&gt;
&lt;div style="color: #3d85c6;"&gt;
print strcspn($alphabet1, $alphabet2);&lt;/div&gt;
&lt;div style="color: #3d85c6;"&gt;
?&amp;gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/other-string-comparison-functions.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-5994360376888849438</guid><pubDate>Mon, 11 Jun 2012 06:00:00 +0000</pubDate><atom:updated>2012-06-11T11:30:08.813+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">compare using php</category><category domain="http://www.blogger.com/atom/ns#">Comparing Two Strings</category><category domain="http://www.blogger.com/atom/ns#">how to  compare two string</category><category domain="http://www.blogger.com/atom/ns#">strcmp</category><title>Comparing Two Strings</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
Following the password example just shown, there are many web sites today that force a person to type&lt;br /&gt;
there password in twice to make sure that they truly are setting it to what they want (the chances of typing it&lt;br /&gt;
identically wrong twice is very low). This is accomplished using such tools as strcmp() which is a built-in&lt;br /&gt;
to PHP.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;Function chk_passwds($input1, $input2) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;if (strcomp($input1, $input2) = 0) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print "Passwords are equal, proceed&amp;lt;br&amp;gt;";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}else {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print "Passwords are not equal&amp;lt;br&amp;gt;";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;chk_passwds("doggy1", "Doggy1");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// strcmp is case-sensitive and thus these passwords are not&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;equal&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The strcomp() function has three possible results: 0 means the two strings are equal, -1 means that the first&lt;br /&gt;
string is less than the second string and 1 means that the second string is less than the first string. In the&lt;br /&gt;
example above, all that needs to be tested is if they are equal. It is not necessary to know the exact&lt;br /&gt;
differences between the two strings. Of course, a statement like if ($input1 == $input2) would&lt;br /&gt;
serve the same purpose, but would not result in the same output type.&lt;br /&gt;
&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/comparing-two-strings.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-5686396746270264992</guid><pubDate>Mon, 11 Jun 2012 04:30:00 +0000</pubDate><atom:updated>2012-06-11T10:00:00.967+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Comparing Strings</category><category domain="http://www.blogger.com/atom/ns#">php  regular expressions to compare strings</category><category domain="http://www.blogger.com/atom/ns#">String Length</category><title>Comparing Strings</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
As stated, PHP has poweful regular expressions that provide programmers with the tools necessary to&lt;br /&gt;
complete difficult searching tasks. In addition to this regular expression capability, PHP provides built-in&lt;br /&gt;
functionality for performing a wide range of string-specific tasks. Many of these tasks are based on string&lt;br /&gt;
comparison operations.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: red;"&gt;String Length&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
One of the simplest comparison operators of strings is determining if the lengths are equivalent. This&lt;br /&gt;
involves determining the length of the strings and then acting upon those lengths. The length function&lt;br /&gt;
built-in to PHP is strlen() and is one of the more widely used string expressions.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;function chk_passwd($input) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;if (strlen($input) &amp;lt; 7) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print "Password is too short";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;} else if (strlen($input) &amp;gt; 10) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print "Password is too long";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}else {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print "Password is the proper length, proceed&amp;lt;br&amp;gt;";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;chk_passwd("doggy1");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;chk_passwd("Diabolical");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;chk_passwd("rst 4567");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;chk_passwd("run-^$#&amp;amp;");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;chk_passwd("mydogspotruns");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
In the above example, the length of the password is the only test being evaluated. Of course, this would not&lt;br /&gt;
be acceptable by itself; however, it does show how length can be used as a string test.&lt;br /&gt;
&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/comparing-strings.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-4095152589461564172</guid><pubDate>Sun, 10 Jun 2012 05:30:00 +0000</pubDate><atom:updated>2012-06-10T11:00:00.993+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">how does preg_split works</category><category domain="http://www.blogger.com/atom/ns#">how does split works</category><category domain="http://www.blogger.com/atom/ns#">Perl-style regular expressions</category><category domain="http://www.blogger.com/atom/ns#">preg_split</category><category domain="http://www.blogger.com/atom/ns#">preg_split()</category><title>Perl-style regular expressions(preg_split )</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;preg_split -&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; This Perl-style function is equivalent to the split() function previously discussed with the&lt;br /&gt;
exception of allowing Perl-style regular expressions. The third optional component of the&lt;br /&gt;
preg_split() function can be entered to limit the number of changes that take place. Failing to enter a&lt;br /&gt;
numeric limit (or a -1), ensures that there is no limit on the changes that can take place.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$csv_text = "5, \"Amsterdam\", \"NLD\", \"Noord-Holland\",&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;731200";&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$csv_array = preg_split("/\,/",$csv_text);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;foreach ($csv_array as $csv_column) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print "$csv_column&amp;lt;br&amp;gt;";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The script above creates an array called $csv_row that contains the following element: [0] = 5,&lt;br /&gt;
[1]="Amsterdam", [2]="NLD", [3]="Noord-Holland", [4]=731200). The foreach iterative control&lt;br /&gt;
statement prints each of these elements on the screen on their own lines. A third component can be&lt;br /&gt;
placed in the split function that would limit the number of array elements that would be created. By&lt;br /&gt;
adding 3 to the split function in the above script (preg_split("/\,/",$csv_text, 3) the&lt;br /&gt;
array elements that would be created would consist of: [0]=5, [1]="Amsterdam", [2]="NLD", "Noord-&lt;br /&gt;
Holland", 731200.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/perl-style-regular-expressionspregsplit.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-5725962528521241393</guid><pubDate>Sun, 10 Jun 2012 04:30:00 +0000</pubDate><atom:updated>2012-06-10T10:00:00.464+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">example of preg_replace_callback()</category><category domain="http://www.blogger.com/atom/ns#">Perl-style regular expressions</category><category domain="http://www.blogger.com/atom/ns#">preg_replace_callback</category><category domain="http://www.blogger.com/atom/ns#">preg_replace_callback()</category><category domain="http://www.blogger.com/atom/ns#">replacement procedure</category><title>Perl-style regular expressions( preg_replace_callback)</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;preg_replace_callback() -&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; With preg_replace(), the function itself is responsible for handling the&lt;br /&gt;
replacement procedure. With preg_replace_callback(), the handling of the replacement procedure is&lt;br /&gt;
handed off to another function to take care of. The syntax is identical to preg_replace() except where&lt;br /&gt;
the replacement text would be located, a function name is present. This function is responsible for&lt;br /&gt;
handling any of the replacement changes to the text that matches the pattern searched.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "Dear &amp;lt;pnm&amp;gt;S&amp;lt;/pnm&amp;gt;Ortiz,&amp;lt;br&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;I&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;would like to thank you and &amp;lt;pnf&amp;gt;F&amp;lt;/pnf&amp;gt;Picard for taking the&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;time in talking to me today. Please feel free to contact me if&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;you have any additional&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;questions.&amp;lt;br&amp;gt;Sincerely,&amp;lt;br&amp;gt;&amp;lt;pnm&amp;gt;E&amp;lt;/pnm&amp;gt;Bob Riker";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;function proper_name_m($matches) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$titles = array(&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;'E' =&amp;gt; 'Mr. ',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;'S' =&amp;gt; 'Sr. ',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;'F' =&amp;gt; 'M ');&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;if (isset($titles[$matches[1]])) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;return $titles[$matches[1]];&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;} else {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;return $matches[1];&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;function proper_name_f($matches) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$titles = array(&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;'E' =&amp;gt; 'Ms. ',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;'S' =&amp;gt; 'Sra. ',&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;'F' =&amp;gt; 'Mme ');&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;if (isset($titles[$matches[1]])) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;return $titles[$matches[1]];&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;} else {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;return $matches[1];&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$new_text = preg_replace_callback("/&amp;lt;pnm&amp;gt;(.*)&amp;lt;\/pnm&amp;gt;/U",&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;'proper_name_m', $text);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$final_text = preg_replace_callback("/&amp;lt;pnf&amp;gt;(.*)&amp;lt;\/pnf&amp;gt;/U",&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;'proper_name_f', $new_text);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print $final_text;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
In the code presented above, a letter (which looks like a follow-up to a sales or interview meeting) has&lt;br /&gt;
been written. The user did not know the proper titles to use with the names, so they were taught to&lt;br /&gt;
place 'E' for English titles, 'S' for Spanish titles and 'F' for French titles. In addition, because of the&lt;br /&gt;
need to address both genders, they were also taught to identify the gender in the tags used:&lt;br /&gt;
&amp;lt;pnm&amp;gt;$language_code&amp;lt;/pnm&amp;gt; for male and &amp;lt;pnf&amp;gt;$language_code&amp;lt;/pnf&amp;gt; for female. The function&lt;br /&gt;
proper_name_m handles the replacement for the &amp;lt;pnm&amp;gt; tags and proper_name_f handles the&lt;br /&gt;
&amp;lt;pnf&amp;gt; tags. The first preg_replace_callback function handles the changing of the male titles&lt;br /&gt;
and then places the new text into the variable $new_text. The second&lt;br /&gt;
preg_replace_callback function handles the changing of the female titles and then finalizes&lt;br /&gt;
the text by placing the replaced contents in the variable $final_text.&lt;br /&gt;
&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/perl-style-regular-expressions_10.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-2169552403345921282</guid><pubDate>Sat, 09 Jun 2012 05:00:00 +0000</pubDate><atom:updated>2012-06-09T10:30:04.018+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Perl-style regular expressions</category><category domain="http://www.blogger.com/atom/ns#">preg_replace</category><category domain="http://www.blogger.com/atom/ns#">replacement characters</category><category domain="http://www.blogger.com/atom/ns#">replacing all occurrences of the pattern searched</category><title>Perl-style regular expressions( preg_replace)</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;preg_replace() -&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; This Perl-syntax function is equivalent to the ereg_replace() function. This&lt;br /&gt;
function works by replacing all occurrences of the pattern searched with the replacement characters&lt;br /&gt;
and then returns the modified result. The fourth parameter is optional, but when a number is entered&lt;br /&gt;
it determines how many occurrences of the pattern searched will be replaced. If no number is entered,&lt;br /&gt;
all occurrences of the search pattern will be replaced.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$url = "MySQL http://www.mysql.com";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print preg_replace("/http:\/\/(.*)/","&amp;lt;a&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;href=\"\${0}\"&amp;gt;\${0}&amp;lt;/a&amp;gt;",&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$url);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The script above changes the http reference to be replaced with the HTML code required to create a&lt;br /&gt;
web link. The three components of this function include the pattern to search for ("/http:\/\/(.*)/"), the&lt;br /&gt;
replacement string ("&amp;lt;a href=\"\${0}\"&amp;gt;\${0}&amp;lt;/a&amp;gt;") and then finally the variable that is going to be&lt;br /&gt;
searched and replaced. The ${0} tells the preg_replace() function to repeat the complete matched&lt;br /&gt;
pattern (in this case http://www.mysql.com).&lt;br /&gt;
In addition to individual variables, the pattern and replacement components can also be arrays. The&lt;br /&gt;
function will cycle through each element of each array, making replacements as they are found.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "The dog barks, the bear growls and the cat meows";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$adults = array("/dog/", "/bear/", "/cat/");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$children = array("puppy", "cub", "kitten")&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print preg_replace($adults,$children, $text);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/perl-style-regular-expressions.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-8546255310536472134</guid><pubDate>Sat, 09 Jun 2012 04:30:00 +0000</pubDate><atom:updated>2012-06-09T10:00:01.230+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">find all occurrences</category><category domain="http://www.blogger.com/atom/ns#">how to  places a backslash in front of all special regular expression characters</category><category domain="http://www.blogger.com/atom/ns#">Perl-style regular expressions</category><category domain="http://www.blogger.com/atom/ns#">preg_match_all</category><category domain="http://www.blogger.com/atom/ns#">preg_quote</category><title>More on Perl-style regular expressions</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;preg_match_all() -&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;This function is similar to preg_match(); however, rather than searching for just&lt;br /&gt;
one occurrence of the search parameter, this function will find all occurrences. In addition, each&lt;br /&gt;
occurrence found will be placed into an array variable entered into the third input parameter. The&lt;br /&gt;
array created will contain various sections of the subpatterns contained in the search pattern. Just like&lt;br /&gt;
preg_match(), if there is a match, the function returns a TRUE, if the regular expression does not&lt;br /&gt;
find a match, a FALSE is returned.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "mysql_close, mysql_connect and mysql_error are&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;all PHP functions used when working with MySQL.";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;if (preg_match_all("/mysql\w+/",$text,$mysql_commands) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print_r($mysql_commands);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;} else {&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print "No mysql commands were found";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;preg_quote() -&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; This function places a backslash in front of all special regular expression characters.&lt;br /&gt;
This is useful if a run-time string containing special regular expression characters has to be evaluated.&lt;br /&gt;
The special regular expression characters are: . \ + * ? [ ^ ] $ ( ) { } = ! &amp;lt; &amp;gt; | :&lt;br /&gt;
&lt;br /&gt;
&lt;div style="color: #3d85c6;"&gt;
&amp;lt;?php&lt;/div&gt;
&lt;div style="color: #3d85c6;"&gt;
$text = "The rental is $300";&lt;/div&gt;
&lt;div style="color: #3d85c6;"&gt;
print preg_quote($text); // Returns "The rental is \$300"&lt;/div&gt;
&lt;div style="color: #3d85c6;"&gt;
?&amp;gt;&lt;/div&gt;
&lt;br /&gt;
&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/more-on-perl-style-regular-expressions.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-1878221699311140497</guid><pubDate>Fri, 08 Jun 2012 05:00:00 +0000</pubDate><atom:updated>2012-06-08T10:30:07.362+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">preg_grep</category><category domain="http://www.blogger.com/atom/ns#">preg_match</category><category domain="http://www.blogger.com/atom/ns#">searching strings using Perl-style regular expressions</category><category domain="http://www.blogger.com/atom/ns#">Using Perl-style regular expressions</category><title>Using Perl-style regular expressions</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
Within PHP there are seven functions used for searching strings using Perl-style regular expressions:&lt;br /&gt;
&lt;br /&gt;
•&lt;span style="color: red;"&gt; preg_match() -&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;This function utilizes the Perl-style regular expressions to search strings provided for&lt;br /&gt;
a match. If there is a match, the function returns a TRUE, if the regular expression does not find a&lt;br /&gt;
match, a FALSE is returned.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$phone_number = "1900Atlanta";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;if (preg_match("/.\D/",$phone_number)) print "The Phone&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;Number must contain only numeric digits";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
• &lt;span style="color: red;"&gt;preg_grep() -&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;This function is similar to the preg_match() function, but works only on arrays. The&lt;br /&gt;
preg_grep() function is also useful in that it creates a new array based on those matches found in the&lt;br /&gt;
search array.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$product_codes = ("NZ3456", "SUS5678", "SNZ3294", "US4678");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$NZ_Codes = preg_grep("/NZ/", $product_codes);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print_r($NZ_Codes); //NZ3456 and SNZ3294 are displayed&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The preg_grep() function can also take a third input parameter that has a unique capability. By&lt;br /&gt;
placing the words PREG_GREP_INVERT in the third input parameter, only those elements that do&lt;br /&gt;
not match the parameter searched for are returned. Using the example above, the opposite elements&lt;br /&gt;
would be returned:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$product_codes = ("NZ3456", "SUS5678", "SNZ3294", "US4678");&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$non_nz_Codes = preg_grep("/NZ/", $product_codes,&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;PREG_GREP_INVERT);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print_r($non_nz_Codes); // SUS5678and US4678are displayed&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/using-perl-style-regular-expressions.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-2377159157459912647</guid><pubDate>Fri, 08 Jun 2012 04:30:00 +0000</pubDate><atom:updated>2012-06-08T10:00:01.989+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Metacharacters</category><category domain="http://www.blogger.com/atom/ns#">Modifiers</category><category domain="http://www.blogger.com/atom/ns#">Perl-style</category><category domain="http://www.blogger.com/atom/ns#">Quantifiers</category><title>Perl-style</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
The Perl programming language is exceptional at parsing strings by providing a comprehensive regular&lt;br /&gt;
expression language to the programmer. Rather than creating their own regular expression language, the&lt;br /&gt;
developers of PHP made the Perl regular expression syntax available to PHP users. The Perl-style regular&lt;br /&gt;
expression syntax was built from the POSIX regular expression syntax and thus hold many of the same&lt;br /&gt;
features. In fact, PHP programmers can use many of the same POSIX regular expression syntax when&lt;br /&gt;
using Perl-style regular expression syntax. The basic Perl-style regular expression syntax involves using&lt;br /&gt;
forward slashes (/ /) to identify the pattern that will be searched for: /mysql/ will find any string that&lt;br /&gt;
contains the pattern "mysql", /m+/ will find any string that contains the letter "m" followed by one or more&lt;br /&gt;
characters (mysql, mom, mudd, my, etc.) and /m{2,4}/ will find any string that contains the letter "m"&lt;br /&gt;
followed by 2 or 4 characters (mom, mysql, etc.). The Perl-style regular expressions are utilized in three&lt;br /&gt;
methods: Quantifiers, Modifiers and Metacharacters.&lt;br /&gt;
&lt;br /&gt;
• Quantifiers - The quantifiers used in Perl-style regular expressions are identical to those used in&lt;br /&gt;
POSIX ERE's.&lt;br /&gt;
&lt;br /&gt;
• Modifiers - These are specific commands that allow for a more defined search based on the&lt;br /&gt;
specific needs of that search. These commands work by being added to the standard Perl-style&lt;br /&gt;
regular expressions. The following is a list of the most common Perl-style modifiers:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&#1048707; i - performs a case insensitive search (ex. /mysql/i will find "mysql" and "MYSQL" or any&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; other combination of upper and lower case characters).&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&#1048707; g - finds all occurrences of the search pattern (ex. /iss/g will find 2 occurrences of "iss" in&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; "Mississippi"). This is useful when performing a global search and replace.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&#1048707; m - performs the search based on individual lines in a multiple line string. For example, when&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;using the characters ^ (which is for matching at the beginning of the string) or $ (which is for&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;matching at the end of the string), the programmer can search a string with multiple lines as if&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;they were individual lines. (ex. /^Thomas/ would not be matched against the following&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;sentence but /^Thomas/m would be: "My mother went to the store.\nThomas went with her.")&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&#1048707; x - this Perl-style modifier will ignore white space and comments within the regular&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; expression.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&#1048707; U - this Perl-style modifier will stop the searching after the first occurrence of the pattern is&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; found.&lt;br /&gt;
&lt;br /&gt;
• Metacharacters - These are specific characters that are preceded by a backslash that symbolize a&lt;br /&gt;
special meaning for the character following. The following are a few of the metacharacters&lt;br /&gt;
associated with Perl-style regular expressions:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#1048707; \A - matches patterns only at the beginning of the string&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#1048707; \b - matches a word boundary (ex. /\bis\b/ will find only occurrences of "is" but not words&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; like "dish" or "mist", /is\b/ would find not only "is" but also "his" because the boundary is&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; looking for the only "is" at the end of the word, ignoring what would be in front of it). \B&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ignores word boundaries.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#1048707; \d - matches any numeric digit character. \D is the opposite matching any non-numeric&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;character.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#1048707; \s - matches a white space character. \S matches non-white space characters.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Other metacharacters that do not require the backslash include:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#1048707; $ - matches patterns at the end of the line&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#1048707; ^ - matches pattern at the beginning of the line&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#1048707; . - matches any pattern except for the new line&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &#1048707; ( ) - encloses a character grouping&lt;br /&gt;
&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/perl-style.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2401702757274511569.post-460515670148975841</guid><pubDate>Thu, 07 Jun 2012 04:30:00 +0000</pubDate><atom:updated>2012-06-07T10:00:00.900+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">converts each alphabetical character into its equivalent lower and upper case</category><category domain="http://www.blogger.com/atom/ns#">POSIX regular expressions(SQL)</category><category domain="http://www.blogger.com/atom/ns#">sql POSIX regular expressions</category><category domain="http://www.blogger.com/atom/ns#">sql_regcase</category><title>POSIX regular expressions(SQL)</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
•&lt;span style="color: red;"&gt; sql_regcase -&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;This function converts each alphabetical character into its equivalent lower and upper&lt;br /&gt;
case representation surrounded by brackets. For those characters that are not alphabetical, no change&lt;br /&gt;
is taken place.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;$text = "MySQL's website is http://www.mysql.com";&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;print sql_regcase($text);&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// Outputs [Mm][Yy][Ss][Qq][Ll]'[Ss] [Ww][Ee][Bb][Ss][Ii][Tt]&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// [Ee] [Ii][Ss] [Hh][Tt][Tt][Pp]://[Ww][Ww][Ww].[Mm][Yy][Ss]&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;// [Qq][Ll].[Cc][Oo][Mm]&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #3d85c6;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;</description><link>http://urwebsite.blogspot.com/2012/06/posix-regular-expressionssql.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item></channel></rss>