匹配数组键

时间:2010-07-12 11:11:07

标签: php arrays foreach

我有这个数组,

Array
(
    [campaign_title] => adasdasdasddsad
    [campaign_keyword] => asdsadasdasdasdasd
    [introduction] => asdasdasdasdasdasdsa
    [campaign_headline] => Array
        (
            [0] => asdasdasdasdasdasdad
        )

    [article] => Array
        (
            [0] => asdasdasdasdasdasdasdasdsadas
        )
    [save_multiple] => Save
)

基本上我需要将campaign_headline和article数组发送到数据库,以便将每个标题和文章保存到同一行,然后将下一个标题和文章保存到同一行等

1 个答案:

答案 0 :(得分:1)

foreach ($x['campaign_headline'] as $key => $headline)
{
    store_into_db($headline, $x['article'][$key]);
}

function store_into_db($headline, $article)
{
    /* there you must store article into DB, i can write this code but i must more infomraiton about, db server type and tables password etc. */
}