本文介绍了用反斜杠分隔文本\?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了几个小时.如何用"\"

I've searched for hours.How can I separate a string by a "\"

我需要将HORSE \ COW分为两个单词,并丢失反斜杠.

I need to separate HORSE\COW into two words and lose the backslash.

推荐答案

$array = explode("\\",$string);

这将为您提供一个数组,对于"HORSE \ COW" ,它将给出 $ array [0] ="HORSE" $ array [1] ="COW" .使用"HORSE \ COW \ CHICKEN" $ array [2] 将是"CHICKEN"

This will give you an array, for "HORSE\COW" it will give $array[0] = "HORSE" and $array[1] = "COW". With "HORSE\COW\CHICKEN", $array[2] would be "CHICKEN"

由于反斜杠是转义字符,因此必须用另一个反斜杠将其转义.

Since backslashes are the escape character, they must be escaped by another backslash.

这篇关于用反斜杠分隔文本\?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-24 04:50