When storing big text contents in a database, it is better to store after compressing the data. The following is an example storing HTML contents in a database cache. We first create a table mapping URLs to HTML contents. The…
When storing big text contents in a database, it is better to store after compressing the data. The following is an example storing HTML contents in a database cache. We first create a table mapping URLs to HTML contents. The…
PHP provides str_pad() to add a string to a certain length with another string. Another way is to use sprintf() with formatting patterns. Pad leading zeros to get exactly 3 digits:
PHP function substr() allows manipulating a string for the rear. The function is defined as below. It returns the portion of string specified by the start and length parameters. If start is negative, the starting position is counted from the…
Social network messages often use hashtags and username mentions to build connections. For example, following message mentions username such as @dummyuser and has hashtags such as #dummytag. The following examples show how to retrieve and replace hashtags and mentions using…