Skip to content

How to split text based on specific word

I have a text which contains the word “Article” many times for example: My text title Article 1 bla bla Article 2 bla bla … I want to split the text like this: Answer Instead of trying to find a split pattern, you should look for a matching pattern: It matches Article, followed by anything u…

Optimizing regex for sentence sanitizer

This is a sentence sanitizer. This is the test sentence: hello [[[[[[]]]]]] friend…..? how are you [}}}}}} It should return: hello friend…..? how are you But instead it is returning: hello friend. .. .. ? how are you. So there are 2 problems and I can’t find a solution around them: the set o…

CakePHP cannot find UsersController

I have been following the blog tutorial on cakephp.org and I had adding and editing the posts table working fine. I wanted to add a user login but I am having trouble when following the tutorial. When …

PHP MySQL Insert Ignore Inserting Too Much Data

I have a traffic exchange and every time a site is viewed I want it to insert in to a table which looks like: -user -site The user is default of 1 and I don’t insert in to it because I thought for an INSERT IGNORE you need a column that stays in the same. My current query: I have

Calculate the number of months between two dates in PHP?

Without using PHP 5.3’s date_diff function (I’m using PHP 5.2.17), is there a simple and accurate way to do this? I am thinking of something like the code below, but I don’t know how to account for leap years: I’m trying to work out the number of months old a person is. Answer You may …