0

I am using a CMS for adding a new product. Along with adding the product I am giving an option to add keywords.

Keywords:<textarea rows="10" cols="20" name="keywords"></textarea>

Then it is inserted in to mysql table. But i want to use these keywords for a search option. Now it is saving as a string of sentences seperated by comma or space. How can I get each word back from the table?

arunrc
  • 628
  • 2
  • 14
  • 26

3 Answers3

0

You can find functions that deals with string-splitting here and here

Nir Alfasi
  • 53,191
  • 11
  • 86
  • 129
0

You can use the PHP method: explode($delimiter, $string).

Example:

$newArray = explode(' ', $yourPhraseWithSpaces);

or

$newArray = explode(',', $yourPhraseWithCommas);
Silvio Delgado
  • 6,798
  • 3
  • 18
  • 22
0

by using

array preg_split ( string $pattern , string $subject [, int $limit = -1 [, int $flags = 0 ]] ) 

or

 explode($delimiter,$string)

or

  spliti ( string $pattern , string $string [, int $limit = -1 ] )

or

  chunk_split ( string $body [, int $chunklen = 76 [, string $end = "\r\n" ]] )

or

  str_split ( string $string [, int $split_length = 1 ] )
chaitu
  • 599
  • 1
  • 6
  • 13