I have a column name descrption in a table..
descrption contains multiple rows like
claim for my new mercedes

purchase my new car

-----
I am trying to explode each row and save each entery in a new column.
claim :save in split1
for:save in split2
my:save in split3
new:save in split4
mercedes:save in split5

Use explode and implode and form an SQL statement:

$values = explode(' ', "claim for my new mercedes");
$sql = "INSERT INTO mytable VALUES ('" . implode("','", "$values") . "')";

Or use str_replace and form an SQL statement:

$sql = "INSERT INTO mytable VALUES ('" . str_replace(' ', "','", "claim for my new mercedes") . "')";

This works only if you use space as a separator. Note that all values in the query are enclosed in quotes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.