PHP Snippets

PHP snippets that would help in solving quick and easy problems


How to parse url using php

snippets

How to parse url using php In certain cases, even in my recent made cpanel plugin, I had to parse the url for me to clear their resource cache. The use cases for this are a lot, there are a lot of manipulation reasons for this as well as solutions. Scenario I’ll take the same

How to explode a string on upper case characters

snippets

How to explode a string on upper case characters Problem You have a string with the following value “thisStringMustBeSplittedAfterUpperCase” and you want to obtain every word separately in an array, splitted after upper case. Solution

Output The output of the $chunks array obtained with a var_dump($chunks) will be:

Solution in a function

How to strip all spaces out of a string in php

snippets

How to strip all spaces out of a string in php You have a string stored in a PHP variable, and you want to eliminate all whitespaces or spaces from that string with PHP, not only from the beginning or the end of the string. Scenario

Solution for spaces

Solution for whitespaces

Request an article ←