hits counter
  Create Free Blog | Random Blog »   Report Abuse | Login   

 

Tag Archive 'explode() vs. split()'

Jun 12 2009

PHP: explode() vs. split()

Published by priyankaparekh under php

explode() isn’t the same as split()!

Since I learned Perl before PHP, I prefer using split() and join() instead of explode() and implode(), respectively. To my surprise, split() is not an alias of explode() while join() is an alias of implode().

The biggest difference is explode() takes a delimiter to split by, while split() takes a regular expression. This means that explode() is going to execute faster. Also, the PHP documentation says that preg_split() is faster than split(), so really there isn’t much of a reason to use split() at all.

No responses yet