私は文字列の配列を持っています:
array('name is required','email is required','email is not valid','ip is not valid')
これらの文字列を次のように単一の文字列に連結する最良の方法は何ですか:
name, email is required. email, ip is not valid
私は文字列の配列を持っています:
array('name is required','email is required','email is not valid','ip is not valid')
これらの文字列を次のように単一の文字列に連結する最良の方法は何ですか:
name, email is required. email, ip is not valid
ここで私はアドバイスをします
<?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";