-2

私は文字列の配列を持っています:

array('name is required','email is required','email is not valid','ip is not valid')

これらの文字列を次のように単一の文字列に連結する最良の方法は何ですか:

name, email is required. email, ip is not valid
4

2 に答える 2

-1

ここで私はアドバイスをします

<?php
define("DELIMITER", "is");
$a = array('name is required','email is required','email is not valid','ip is not valid');
foreach($a as $k=>$v){
    $arr = explode(DELIMITER, $v, 2);
    $subject = trim($arr[0]);
    $description = trim($arr[1]);
    $res[$description][] = $subject;
}
foreach($res as $k=>$v){
    echo implode(",", $v)." ".DELIMITER." ".$k.". ";
}
echo "\n";
于 2013-08-27T11:14:24.293 に答える