0
<?PHP

// primarily a method for storing data
// arrays are counted from 0

$hosts = array(
array("ronmexico.kainalopallo.com/","beforename=$F_firstname%20$F_lastname&gender=$F_gender","Your Ron Mexico Name is ","/the ultimate disguise, is ([^<]+)<\/b><\/u>/s"),<u><b>([^<]+)<\/b><\/u>/s"),

array("rumandmonkey.com/widgets/toys/mormon/index.php","gender=$F_gender&firstname=$F_firstname&surname=$F_lastname","Your Mormon Name is ","/
My <p>My Mormon name is
<b>([^<]+)<\/b>!<br \/>/s")
);

return $hosts;

?>

How to store this array into mysql database.

1

3 Answers 3

1

just iterate the array and insert every element into the table

foreach($hosts as $key => $value){
    mysql_query('INSERT INTO table (field) VALUES ("'.$value.'")');
}
Sign up to request clarification or add additional context in comments.

Comments

1

You can use the PHP serialize function to store arrays and objects in MySQL

2 Comments

+1 for answer but OP should avoid to store arrays/objects in the database!
@AlexV - totally agree its almost never the right thing to do but in edge cases it can be useful
1

You can use json_encode when storing:

$fruit_color = array("apple" => "red", "banana" => "yellow", "cherry" => "red");
$encoded = json_encode($fruit_color); //Turn your array into json-readable string

And json_decode when retrieving from database:

$result = mysql_fetch_assoc($sql);
$decoded = json_decode( $result[column_name] );

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.