![](/img/trans.png)
[英]Is there a way to compare two strings where one is the parent string and the other a child string and make bold similar substrings?
[英]How to make a string the value of two other strings?
這是一個非常基本的問題,但是我的方法看起來超級笨拙,而且想知道是否還有其他方法可以使它看起來更干凈?
$title = 'Post title Goes Here';
$author = 'Post author Goes Here';
$post_title = ''.$title.' - '.$author.'';
如何使$post_title
看起來不那么難看? 但是出於相同的目的?
$post_title = "$title - $author";
另一種方法是使用數組並內爆。
這樣可以使您的變量“分組在一起”,並且通常使編碼更容易。
$post["title"] = 'Post title Goes Here';
$post["author"] = 'Post author Goes Here';
$post_title = implode(" - ", $post);
// Or to keep it grouped:
$post["post_title"] = implode(" - ", $post);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.