如何使用php将句点替换为项目符号(li)?
我在php中有一个带多个句点的字符串。我试图找出将字符串中的每个句点替换为新行上的项目符号(如何使用php将句点替换为项目符号(li)?,php,Php,我在php中有一个带多个句点的字符串。我试图找出将字符串中的每个句点替换为新行上的项目符号()。有人对如何做到这一点有什么建议吗 $desc= "Petite Jeans. Petite Fit Guide,Tall Fit Guide Explore our 1969 denim boutique for fit facts, fabric notes, style tips, and more. Fabrication: Premium stretch denim. Wash: Faded
)。有人对如何做到这一点有什么建议吗
$desc= "Petite Jeans. Petite Fit Guide,Tall Fit Guide Explore our 1969 denim boutique for fit facts, fabric notes, style tips, and more. Fabrication: Premium stretch denim. Wash: Faded dark blue. Hardware: Double button closure, zip fly. Features: Five pocket styling. Cut: Mid rise. Fit: Slim through the hip and thigh. Leg opening: Boot cut. Inseams: regular: 33\', tall: 37\', petite: 30\'";
echo $desc;
上面的字符串应该如下所示:
<li>Petite Jeans.
<li>Petite Fit Guide,Tall Fit Guide Explore our 1969 denim boutique for fit facts, fabric notes, style tips, and more.
<li>Fabrication: Premium stretch denim.
<li>Wash: Faded dark blue.
<li>Hardware: Double button closure, zip fly.
<li>Features: Five pocket styling.
<li>Cut: Mid rise.
<li>Fit: Slim through the hip and thigh.
<li>Leg opening: Boot cut.
<li>Inseams: regular: 33\', tall: 37\', petite: 30\'
小牛仔裤。
小合身指南、高合身指南探索我们1969年的牛仔精品店,了解合身事实、面料说明、风格提示等。
制作:优质弹力牛仔布。
水洗:褪色的深蓝色。
硬件:双按钮关闭,拉链飞。
特点:五口袋设计。
剪:中高。
修身:臀部和大腿修身。
腿部开放:靴子切割。
内接缝:普通:33英尺,高:37英尺,娇小:30英尺
只要您确定每个周期都可以被替换,您需要的是内爆()
和爆炸()
:
$desc=''。内爆(' ',爆炸('.',$desc))。'李>';
只要您确定每个周期都可以被替换,您需要的是内爆()
和爆炸()
:
$desc=''。内爆(' ',爆炸('.',$desc))。'李>';
你试过了吗
$bulletted = str_replace(".", "<br />•", $desc);
$bulletted=str_replace(“.”,“
&bull;”,$desc);
看你试过了吗
$bulletted = str_replace(".", "<br />•", $desc);
$bulletted=str_replace(“.”,“
&bull;”,$desc);
请参见使用:
$desc=''。str_replace(“.”,“ ”,$desc)。”李>';
使用:
$desc=''。str_replace(“.”,“ ”,$desc)。”李>';
我可以提供一个足够简单的解决方案,只要每行末尾只有一个周期,并且一行中不超过一个周期。是这样吗?我可以提供一个足够简单的解决方案,只要每行末尾只有一个周期,并且一行上不超过一个周期。是这样吗?
$desc = '<li>' . str_replace('.','</li><li>', $desc) . '</li>';