Tag Archives: string

Parse JSON, XML and HTML – jQuery

In this post, find out jQuery code on how to parse JSON, parse XML and parse HTML. If you are still using custom code for parsing any of these and making your life more miserable then stop doing it. Why? If you are not aware then here is a news for you that jQuery has inbuilt utility methods for each. Which are, parseJSON() parseXML() parseHTML() Using parseJSON() This method takes a well-formed JSON string and returns the resulting JavaScript object. […]

Php Interview Questions and Answers – Part 1

1- What’s PHP ? The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications. 2- What Is a Session? A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests. There is only one session object available to your PHP scripts at any time. Data saved to the session by […]

Remove Repeated Words in String – PHP

Usually we do remove duplicate words from a string using array functions etc, But it’s very slow doing that way because of the size of the string. The fastest way to achieve the same result is PHP regex. You can remove duplicate words using PHP regular expressions with preg_replace. Below is a complete PHP example code using regular expression to remove duplicate words from a string. <?php $text =‘one one, two three, two’; $result_text = preg_replace(“/\b(\w+)\s+\\1\b/i”, “$1″, $text); echo “Result […]