-3

I want to split variable php value into two parts. Inside a script that I use I load variables using this code:

{$searchResults.domainName}

The value is always defined like "domain name.com"
I want to splits this into two values

Before and after the dot, so I can load the value "domain" and the value ".com"

How can I achieve that with php?

JGeer
  • 1,768
  • 1
  • 31
  • 75
  • 3
    You should make it clear what it is that you are trying to achieve. This question looks a lot like [this question from 'related'](http://stackoverflow.com/questions/6486524/string-manipulation-into-two-parts-in-php?rq=1). And literally Googling your title, I found [Manual](http://php.net/manual/en/function.explode.php) , [this](http://stackoverflow.com/questions/4731351/split-into-two-variables), [this](http://stackoverflow.com/questions/5159086/php-split-string) , [this](http://stackoverflow.com/questions/4353378/splitting-given-string-into-two-variables-php) and could go on... – FirstOne Dec 27 '15 at 21:58
  • 1
    This question needs more research effort shown. – user4317867 Dec 27 '15 at 23:55

1 Answers1

0

You can use PHP explode for that:

$pieces = explode(".", $domainName);

/

$pieces[0] outputs 'domain'

$pieces[1] outputs 'com'

PHP Explode Manual

Bart Scheffer
  • 497
  • 1
  • 3
  • 18