Jump to content

Help with array!!!!


argrafic

Recommended Posts

Hello all.

 

I'm building some sort of blog and I have the field for the type of cloud or keywords from the post and I'm having tourble thinking how it works.

 

The way I'm doing it is that you have a textfield and you enter the words separated with a space. Then when I catch the value of the textfield I explode it so I have an array of words I would insert into a table in the database associated with the id of the blog post so then I can find the posts depending on the words.

 

But I have been batteling all morning with the array, how to break each part into a single word and then isert that word into the database.

 

I've tried the serialized and unserialized function and can't seem to make it work!!!

 

I hope someone can help me!!  :P

 

Thanks!!!

Link to comment
https://forums.phpfreaks.com/topic/103427-help-with-array/
Share on other sites

well, i found the answer to my question!!!!

 

$string = "This is an example";

$arrayOfString = explode(" ", $string);

foreach($arrayOfString as $word)
{
    echo '<p>The word is: '. $word . '</p>';
}

 

so i made the tweak to use it for what i needed, this is the code i'm using:

$string = $_POST['t_tema'];
$arrayOfString = explode(" ", $string);
foreach($arrayOfString as $word)
{
    $sql="INSERT INTO blog_tema (t_b_id, t_tema)
            VALUES ('5', '$word')";
        
}

Link to comment
https://forums.phpfreaks.com/topic/103427-help-with-array/#findComment-529721
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.