如果,
$_POST['address']
使用space | space
或str_replace()
,我想替换逗号I.e preg_replace()
。像:
$ofa = $_POST['address']
$ofa = str_replace or preg_replace
答案 0 :(得分:1)
你走了:
// allMasterPages is type List<MyPage> - change to whatever it really is
Func<List<MyPage>, List<TopMenuVM>> funcTopMenuVM = null;
funcTopMenuVM = ((pages) => {
return
(from amp in pages
orderby amp.DisplayOrder
select new TopMenuVM()
{
DisplayOrder = amp.DisplayOrder,
Url = string.IsNullOrEmpty(amp.Url) ? GenerateUrl(amp.Page1.OrderBy(x => x.DisplayOrder).FirstOrDefault()) : amp.Url,
PageId = amp.PageId,
PageTitle = amp.PageTitle,
TopMenus = funcTopMenuVM(amp.Page1)
}).ToList();
});
var newTopMenu = new TopMenuVM()
{
TopMenus = funcTopMenuVM(allMasterPages)
};
答案 1 :(得分:1)
你需要这样做:
$address = "some , data , from , post"; // $_POST['address']
$cleanAddress = str_replace(",", " | ", $address);