开发者

i want to add string data to before first character and after last character

开发者 https://www.devze.com 2023-04-11 12:03 出处:网络
Shortly i have string variable similar to this:(ever开发者_如何学运维y li elements is array element.)

Shortly i have string variable similar to this:(ever开发者_如何学运维y li elements is array element.)

<li>first</li>
<li>second</li>
.
.
.

I want get:

<ul>
<li>first</li>
<li>second</li>
    .
    .
    .
</ul>

But require add string data's start and end for this avaible..


$var = "<ul>\n".$oldvar."\n</ul>";

will probably does it


Not really?

$my_string = "foo";
$new_string = "<start>" . $my_string . "<end>";

// $new_string is now "<start>foo<end>"

// or, another option:
$new_string = "<start>$my_string<end>";


This one's easy.

$str = "<li>.....</li>\n"
$strWithUL = "<ul>\n$str</ul>";

Hidden in plain sight :)

0

精彩评论

暂无评论...
验证码 换一张
取 消