Get string of random characters

There are times when you need to get a string of random characters of the specified length. It could be the default password for a new account or a unique identifier for something (you would probably be better off generating a guid) in your database.

Here is a function for those occasions. It generates a string of the specified length consisting of random characters. You can choose which type of characters to include - lowercase, uppercase, numeric or special.

Handy string manipulation functions

Many people like to keep their code tidy, even the final HTML that you can see when selecting "Show source" option in your browser. This includes having correct number of indents for all levels.

It would make the code cluttered and messy if we had to define that we wanted so many tabs to be prepended or a new line character appended (like many often do - $text . "\n").

Here are two functions to avoid that - printLn and sprintLn - they print the text and return the text respectively.

Ensure that the string ends with a specific character

From my times in Delphi I remember three functions (or routines) which were quite useful in working with directories and paths. They both are located in Delphi's SysUtils unit and are called IncludeTrailingBackslash and IncludeTrailingPathDelimiter.

Lately I was doing directory-related tasks and I decided that these functions would come in handy if I had them in PHP so I decided to create my own ports of them.

Replace URLs in the text with page titles

Have you ever wanted to parse comments on your website or blog and replace all links that a user has enered with titles of the respective pages?

Look no further as you have found the answer!

It might look quite complicated at the beginning (if you are not that advanced in PHP) therefore I will try to explain every step involved as thorough as I can.

Showing 1 - 4 of 4 results