Learn Hosting,WebDev,Scripting Make Money Hosting, WebDev,Scripting
Home :: HostScreamer.com
 
   

PHP – String Parser, Find a String Between Two Strings

October 31st, 2009

By Ryan Huff

function get_string_between($string, $start, $end){  

$string = ” ” . $string;

$ini = strpos($string,$start);

if ($ini == 0) return “”;

$ini += strlen($start);

$len = strpos($string, $end, $ini) – $ini;

return substr($string, $ini, $len);

}

//USAGE

echo get_string_between(“this is a test”, “this “, ” a test”); //RETURNS ‘is’

This is a very handy and easy to implement utility for PHP. Simply call the function as shown in order to get the string value between to known string points.

There are three variables that you need to pass to the function, the target text, the left data point and finally the right data point; in that order as well.  The return of the function call is the string value that is between your two data points. It is important to note that the space character, ” ” counts as a valid character so keep that in mind or you’ll lose sleep over trying to figure out why it isn’t working only to realize that you didn’t account for a space somewhere!

The mechanics here are very simple. First, find the integer position of the the left point and then add that to the total  length. Next find the integer position of the right data point starting at the integer position equal to the length of the left point and then subtract that by the total length of the left.

Lastly, return the original string starting at the end of the length of the left string point and ending at the beginning of the right string point.

Ryan Huff is an Internet Marketing and technology coach specializing in start-up business development. You can connect with Ryan at http://mycodetree.com or follow Ryan at http://twitter.com/rthconsultants

Article Source: http://EzineArticles.com/?expert=Ryan_Huff




Which is the Better Choice in Programming – ASP Dot NET Or Php Language?

October 31st, 2009

By John Choo

Several programming languages are used for web designing, but the two most effective and extensively used web programming languages are .Net framework and PHP. It is a bit difficult task to judge and compare the effectiveness for both.

Both of them are of equal importance in terms of swapping information and contacting with different databases. asp.net is an extension of .NET which was manufactured by Microsoft and stands for using on internet application. On the contrary, PHP which stands for Hypertext Pre Processor is used in operating systems such as UNIX and LINUX. Some dissimilarities of PHP and ASP are given below.

Development and designing Cost

Php is an open source which is free to download from internet, it have the largest free module to be download and plug in to use freely which was coding and modified by million of programmer which using Php. The case is totally different as for as asp.net, you will need a series Microsoft product such as windows for operation system, visual studio or dreamweaver for programing, make is costly which compare to writing in Php language.

Application Performance

Php is an interpreted language, meaning it run directly from the code which you writing every time. In other hand, asp.Net is an optimized and compiled language, you may compiled it before upload to productivity. It is commonly accepted and proved many times over that compiled application generally load faster than interpreted ones because interpreted application must be reduced to machine instructions at runtime.

Application Environment

Php application well run on kind of platforms such as Linux, Unix, Windows, Apache as compare to asp.net in default, is only able to run on a window server.

Multiple language support

Php has been made is C++. Most of the computer programmers rely on this programming language and they consider it to be the best ever programming language. Being an extensive of .NET, asp.net capable support various language in a platform such as visual basic.net, cSharp, C++, jSharp and etc. It effective enable different language programmers easily to develop an application together without the gaps.

Database Connectivity

Php language in default is using mySQL as database back end which is also an open source and is free to download; As for asp.net language the default database back end is msSQL, which is not free. But both of them also can be modify the database connection to run on each other default database, also can be modify to run with Microsoft access, oracle and etc.

Conclusion

Wherever developing or designing with asp.net or php is fine, there numbering of websites and amazing applications are written in it by much more experienced coders than myself. That said, you should not choose the language base on speed, as development preference is much more important; use php if you feel it is a superior language.

John Choo is a Malaysia programmer, he own a web design company also offer web design, web application such as CMS.

Article Source: http://EzineArticles.com/?expert=John_Choo