PHP Articles

Remove Characters from String except ASCII

Recently while developing I came across the need to remove all special characters and numbers from a string. Actually, if it wasn’t an ASCII character, I wanted to get rid of it! I needed this for a method I was working on to use for my Auction Alerts site that I have been working on.

I think the best way to go about handling this would be to use a regular expression. To be more specific, I chose to use ereg_replace. I know that this function has been depreciated in PHP v5.3, meh, it still works like a charm. J

Anyway, an example of the code I used was this:

$cleansed_string = ereg_replace("[^A-Za-z ]", "", $string );

Oops, I forgot to mention that I wanted to leave spaces in it for reasons I’ll leave to your imagination. Glorious right? One line of code to filter all that other junk out. Well, I wasn’t done there.

I also needed this method to take out a number of commonly used words. The goal was to really leave in the words that are truly unique to the string. I don’t care about the words like “the, we, am, I, etc…”

$filter_words = array("the","and","it","we") //there are a lot more words in this array than shown
$filtered_string = str_ireplace($filter_words, " ", $cleansed_string);

It’s really as simple as that. You’ll notice that I used str_ireplace. This is a case-insensitive string replace. “The” is the same to me as “the” so I wanted the function to replace all occurrences found for those.

When all is said and done, $filtered_string is the variable that I returned from the method. It doesn’t have any numbers or special characters in it. Not only that, but it doesn’t have the useless crap words in like “I”.

Remove All Numbers from a String

I didn’t need this, but I thought I would add how to do that from this post. It isn’t much different than removing all characters other than the ASCIIs. All you need to really do is change the regular expression a bit.

$cleansed_string = ereg_replace("[^0-9]", "", $string );

BAMM! Done! Now $cleansed_string contains only numbers from the string.

I hope this little post was helpful you some of you. Let me know if you have any better methods for filtering strings like this.


What PHP Project Are You Working On?

So what PHP projects have you been involved with lately? Every PHP project that I get involved with seems like it is a two rapid development project. That is, PHP projects that I have been doing for the company that I work with. I have to tell you, I’m not a fan of the rapid development process.

Multiple times I have been approached asking if this type of PHP app can be done. Most of the time, the answer is yes. Then the follow up is, okay we need it done and working in two weeks. Maybe it is my fault for not arguing the due date, but I can’t help it. I get offered too few PHP projects at my 8 to 6 to pass one up.

Rapid Development Process = Poor Documentation

Well, I was able to finish the project in the allotted time given to me, but not in the fashion that I would have liked. I wouldn’t say mistakes have been made in any of these projects, but I will say most of them could have been documented much better. I have a certain feeling of remorse when I think about the next developer that needs to update the code.

Can I go back through the code to document it properly the way it should have been done in the first place when I have a free second? Sure, but with company budget cuts and co-employees being laid off (working in the heart of Michigan), I’m making less and doing twice as much. So yeah, I’ll get to it when I have a free second.

Maybe I’ll do another post on RDP in the future, because I feel this process warrants more discussion. For now however, let’s talk about our projects.

My PHP Projects

Getting away from the topic of my day job, in my moonlight hours I have been working on Auction Alerts as you may have noticed from my previous post. This site integrates the eBay API largely to help find eBay deals, although the Amazon API is being used as well, but sparingly. I was thinking about implementing the Shopping.com API into the site, but I need to look through their documentation a little more to understand how I could best integrate it into the site.

Register with Auction Alerts

I have given the site a new theme to match its blog’s. This project has been taking up most of my free time while not at work. I’m considering taking it out of beta soon because it is being used by a medium sized group of people and for the last month there haven’t been any issues. If you haven’t checked this site out, I would appreciate it if you could take a moment to look it over and tell me what you think.

What PHP projects are you working on?

If you are a developer yourself and would like a free plug to the project that you are working on or one that you have done in the past. The community here would to hear about it.

You can either email me a post explaining your project and what is does or you are always welcome to sign up with BrownPHP and I can make you an author from which you can just write the post here on this site. You would just have to let me know.


Take Control of Your Web Presence With a PHP Tutorial Script


A PHP tutorial script is a way to learn PHP language. PHP scripting is a powerful computer language for creating flexible, attention grabbing and interactive websites. Once you have learned by practicing in a PHP tutorial script you can script your own websites on the server-side of whatever Internet service provider you are using.

A PHP tutorial script will give you the ability to use the widespread, free, and open source alternative language to others such as Microsoft’s ASP. PHP tutorial script learning is perfectly suited for Web development and the code itself can be embedded directly into the HTML code of the Internet.

The PHP tutorial script will show you how the syntax of the language is very similar to Perl and C two other language precursors to PHP. PHP is often used in combination with Apache, a web server program on various operating systems such a Windows, Vista and Mac OSX. It also supports ISAPI and can be used with Microsoft’s IIS on Windows.

To make best use of the PHP tutorial scripts for learning and then developing websites you really need a basic grasp of HTML, the mother tongue of the Internet and some scripting experience. PHP actually stands for Hypertext Preprocessor and is very like ASP in that you do not need to use your computer capacity to use it as it sits on the server of the ISP yo are working with.

The PHP tutorial script lessons will quickly make you familiar with real PHP scripts that run on the server. PHP tutorial scripts will also let you see how PHP works with

Many databases such as MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.

The PHP tutorial script qualification will give you entry into the PHP open source software community where you will contribute to the development of this web design tool. The PHP tutorial scripts and the PHP sotware is free to download and use.

The PHP tutorial scripts will be just like real PHP files and can contain text, HTML tags and scripts. When you script in PHP it is uploaded to the browser as plain HTML but PHP files have a file extensions of “.PHP”, “.PHP3″, or “.phtml”

If you have a server that supports PHP you don’t need to do anything. Simply use your PHP tutorial script knowledge to create some .PHP files in your web directory, and your server will parse them for you. Precisely because it is free, most web hosts offer PHP support.

When PHP reads a file, it picks out the opening and closing tags, which are PHP flags to start and stop operating the code between them. Parsing in this way allows PHP to be linked into all sorts of different documents, as everything outside of the opening and closing tags is unreadable the PHP parser. Most of the time, as the PHP tutorial scripts show, you will see PHP embedded in HTML documents.

►1X BRISK AR12ZS Spark Plug SUZUKI AN250 AN650 BURGMAN=U24ETR,RG2PHP,CR8EVX
US $20.38
End Date: Saturday Feb-04-2012 10:39:50 PST
Buy It Now for only: US $20.38
Buy it now | Add to watch list

PHP Frameworks

PHP Frameworks:

PHP is finally getting the attention that i deserves, yes I have always believed that PHP is one of those neglected languages, neglected because they are used in abundance but there isn’t enough programs or as we call them frameworks to work on PHP. But that was until the release of PHP 5. After the release of PHP, there is a range of Frameworks available.

Today we review and understand closely the various frameworks available for PHP. Some of the most popular frameworks for PHP are:

The Zend Framework.
The Prado Framework.
CakePHP Framework.
Symphony Framework.

These frameworks are ofcourse the most popular ones and there are more than 40 frameworks for PHP and it is very difficult to know which framework suits you the best and will be the most productive for your web development and enterprise goals.

Ofcourse all these frameworks are free and provide a host of services to satisfy almost all of the web development needs of a web designer or a website owner. Some of the most common features of all these PHP Framework are as follows:

PHP 5: Thats obvious! All the frameworks support both PHP 5 version of the PHP.Only “The Prado Framework” support the PHP 4.x version of the PHP as well as the PHP 5 version of the PHP.
Multiple DBs: All the above mentioned frameworks support multiple databases to be used without making any setup and configuration changes.
Validation: All the four frameworks have an inbult validation and a filtering component which can be used.
MVC: All the four frameworks have the MVC that is the Model View Controller setup.

So, these are the few components and controllers that are common in most of the PHP based frameworks and therefore one should look out for these components when downloading or using a PHP framework.

Now let us see a brief introduction about each of these PHP based frameworks and their salient features:

Zend Framework:Zend Framework is a component based framework with components for almost all of the programming needs of a PHP programmer or PHP developer.

Some of the components in the Zend Framework are:

zend_acl
zend_auth
zend_cache
zend_config
zend_consolegetop and many more.

Prado Framework: The Prado framework provides the following benefits for web application developers.

reusablility
Ease of use
Robustness
Performance
Team Integration

CakePHP:

Some of the important features of CakePHP are as follows:

Model, View, Controller Architecture
View Helpers for AJAX, Javascript, HTML Forms and more
Built-in Validation
Application Scaffolding
Application and CRUD code generation via Bake
Access Control Lists
Data Sanitization
Security, Session, and Request Handling Components
Flexible View Caching

Like all other frameworks cakePHP is also component based framework.

The Symphony Framework:

Some of the features of the symphony framework are as follows:

simple templating and helpers
cache management
smart URLs
scaffolding
multilingualism and I18N support
object model and MVC separation
Ajax support
enterprise ready

Thus these are the best options available for frameworks relating to PHP and one should review all these features of all these frameworks against his needs and choose the appropriate framework to work on!

Any suggestions and comments as always are welcome.

Beginning Zend Framework (Expert's Voice in Open Sour..
US $5.99
End Date: Wednesday Feb-08-2012 8:43:43 PST
Buy It Now for only: US $5.99
Buy it now | Add to watch list

How PHP Programming Language and Zend Framework are Helpful?

PHP provides support to different databases like Oracle, Sybase, MySQL, etc & it can be easily embedded in to HTML also. It rapidly grew to become much more robust language, but was originally designed for use in Web Site Development. In a nutshell, PHP is most popular because of its functionality which can be changed as per ones requirements.

PHP is the most popular web scripting language as well as a widely used programming language used for web-site development. PHP stands for “Hypertext Preprocessor” but it originally stood for “Personal Home Page” in 1995. It is a brilliant language which was originally designed for producing dynamic web pages for virtually any web application. PHP is a general purpose scripting language that facilitates developer in making dynamically driven websites & it is easy to learn & understand.

In PHP community, PHP frameworks are the newest buzz word from recent years. There’s different kinds of frameworks obtainable & it is lovely for developers to select the right framework. The objective of a framework is make the web-based applications method less hard. This helps in reusing the developed code, intuitive to work with & of work stable. A quantity of the important frameworks are Zend framework, Symfony, CakePHP, Prado & Solar. Among these, Zend framework is the most hyped framework as well as a web based application designed to build complex PHP applications simpler.

Benefits of PHP application development:

- PHP integrates well with HTML which is its primary use i.e. the actual PHP code can be embedded in to HTML code. This enables your web server to method web pages before they are actually displayed in the user’s web browser.

- PHP is an open-source language so it is free. It can be easily installed & you don’t need to pay thousands of dollars to purchase. It is used by millions of people & giant group of developers around the globe.

- PHP is generally human friendly (simple & easy to learn) than other high level programming languages such as C, C++, ASP or ASP.net.

- PHP is versatile which is supported on most web servers & runs on all major operating systems like Mac OS, windows, Linux etc.

- The most recent version of PHP is stable. It is used for web programming much like C / JavaScript, Java & Microsoft C#.

- PHP results in quicker navigation & efficient page loading as its processing speed is faster.

PHP is a well-established language. Its popularity continues to grow rapidly because it is free (it is open-source application), it is speedy (It can be easily embedded in to HTML), have full object oriented support & giant capability to build any sort of application which can run in web browser.
Beginning Zend Framework (Expert's Voice in Open Sour..

US $5.99
End Date: Wednesday Feb-08-2012 8:43:43 PST
Buy It Now for only: US $5.99
Buy it now | Add to watch list


  • BrownPHP Tag Cloud

  • Copyright © 1996-2010 Brown PHP. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress

    Powered by Yahoo! Answers