Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.