Tag Archives: string

Convert variable to string in PHP

snippets

Convert variable to string in PHP PHP is a loosely typed language and assigns types to variables depending what is assigned to it. Sometimes you will want to transform a given variable into a string format and obtain a similar output with “ToString()” method in Java or .NET. This could be done easily with one of the following

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

Converting strings to numbers in javascript

javascript

Converting strings to numbers in javascript There are some situations where you would want to take a string from a place, convert it to a number and put it in another place on the client side. This thing can be obtained by some helper function that are built-in in javascript. In this article we will

Request an article ←