0

implode を使用して、この配列を String に変換したいと思います。

Array ( [0] => Array ( [technologies_id] => 1 [nom] => PHP [type_technologies_id] => 1 [nom_techno] => Developpement web ) [1] => Array ( [technologies_id] => 3 [nom] => ASP3 [type_technologies_id] => 1 [nom_techno] => Developpement web ) [2] => Array ( [technologies_id] => 5 [nom] => JavaScript [type_technologies_id] => 1 [nom_techno] => Developpement web ) [3] => Array ( [technologies_id] => 6 [nom] => CSS [type_technologies_id] => 1 [nom_techno] => Developpement web ) [4] => Array ( [technologies_id] => 7 [nom] => AJAX [type_technologies_id] => 1 [nom_techno] => Developpement web ) [5] => Array ( [technologies_id] => 17 [nom] => HTML [type_technologies_id] => 1 [nom_techno] => Developpement web ) ) Array ( [0] => Array ( [technologies_id] => 8 [nom] => Jquery [type_technologies_id] => 2 [nom_techno] => Frameworks web ) ) Array ( [0] => Array ( [technologies_id] => 22 [nom] => VB 6 [type_technologies_id] => 3 [nom_techno] => Developpement applicatif ) [1] => Array ( [technologies_id] => 23 [nom] => VB.NET [type_technologies_id] => 3 [nom_techno] => Developpement applicatif ) ) Array ( ) Array ( ) Array ( [0] => Array ( [technologies_id] => 28 [nom] => MySQL [type_technologies_id] => 6 [nom_techno] => SGDB(R) ) [1] => Array ( [technologies_id] => 30 [nom] => SQL Server Express [type_technologies_id] => 6 [nom_techno] => SGDB(R) ) [2] => Array ( [technologies_id] => 32 [nom] => SQLite [type_technologies_id] => 6 [nom_techno] => SGDB(R) ) [3] => Array ( [technologies_id] => 34 [nom] => Microsoft Access [type_technologies_id] => 6 [nom_techno] => SGDB(R) ) ) Array ( [0] => Array ( [technologies_id] => 39 [nom] => SQL [type_technologies_id] => 7 [nom_techno] => Langages d'interrogation de bases de donnees ) ) Array ( [0] => Array ( [technologies_id] => 46 [nom] => Windows [type_technologies_id] => 9 [nom_techno] => OS ) [1] => Array ( [technologies_id] => 49 [nom] => MAC OS [type_technologies_id] => 9 [nom_techno] => OS ) ) Array ( [0] => Array ( [technologies_id] => 54 [nom] => Merise [type_technologies_id] => 11 [nom_techno] => Methodologies ) ) 

私はこのように試しました:

$string_comp = implode($competences);

しかし、私はこれを得ました:

アレイアレイアレイアレイアレイアレイ

よろしくお願いいたします。

4

6 に答える 6

4

このカスタム関数を試してください:)

function multi_implode($sep, $array)
{
    $_array = array();

    foreach($array as $val)
    {
        if(is_array($val)) $_array[] = multi_implode($sep, $val);
        else $_array[] = $val;
    }

    return implode($sep, $_array);
}

マルチアレイがあるため、内破が機能していません。

于 2013-11-01T10:27:09.960 に答える
0

アクセス方法にもよりますが、個人的にはjson_encode($myvar);. または、Stackoverflow: Multidimensional Array PHP Implodeで提供されているこの回答をご覧ください。

于 2013-11-01T10:35:09.690 に答える
0

配列の配列があります。次のように、各サブアレイを内破する必要があります。

foreach ($competences as $subArray)
{
    $string_comp .= implode($subArray);
}
于 2013-11-01T10:27:40.120 に答える
0

このようにしてみてください->

$array = array(1,2,3,4);
echo serialize($array);

// Prints

a:4:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;s:3:4;}
于 2013-11-01T10:28:36.380 に答える
0

これを使用するだけです:

$res = '';
foreach ($arr as $item) {
    $res .= implode('', $item);
}
于 2013-11-01T10:29:00.430 に答える
0

文字列形式で出力を取得するには、php のserialize()関数を 使用して、以前の状態としてunserialize()することもできます。

于 2013-11-01T10:30:53.000 に答える