I have an issue that I am trying to figure out, but I'm not having much luck and wondered if anyone could give me some pointers (relative noob I'm afraid).
I have a string which I break down into separate words with the intention of inserting those words into a MySQL database along with a count of the number of times the word is used. For instance,
Code: Select all
$string = "This is a string containing these words. Some of these words need to be added to the database";Code: Select all
$result = Array
(
[0] => string
[1] => containing
[2] => these
[3] => words
[4] => some
[5] => these
[6] => words
[7] => need
[8] => added
[9] => database
)
Word - Count
string - 1
containing - 1
these - 2
words - 2
need - 1
added - 1
database - 1
I understand I can get a word count by using array_count_values($result), but I've no idea how I would go about inserting that kind of data into a MySQL database, using an INSERT statement.
Any pointer in the right direction would be very much appreciated.
Many thanks,
JohnHudson