Tag Archives: split

Transform a csv file to associative array in PHP

csv

 Transform a csv file to associative array in PHP There are a lot of  examples on how to take a CSV file and put it in an array, but the main problem about them is that the header and the rest of the content from the csv are placed on separate keys, both on the

PHP explode equivalent for javascript

snippets

PHP explode equivalent for javascript Very often you have to perform operations on strings to split them, to obtain only a desired piece of it. If the string is formatted in a way that allows you to split, eg. you know the delimiters, you can use the following way to do this. Problem Let’s say

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

Request an article ←