netfrugal Posted October 23, 2006 Share Posted October 23, 2006 I am trying to separate this: mydomain\mynameTo do this I am using the explode function as such:$word = "mydomain\myname";$separated = explode("\", $word);echo $separated[0];echo $separated[1];However, the backslash does not work. Is there a way to explode backslashes? Quote Link to comment https://forums.phpfreaks.com/topic/24857-explode-function-question/ Share on other sites More sharing options...
obsidian Posted October 23, 2006 Share Posted October 23, 2006 Because of the nature of the beast, you need to escape the backslash, and actually use two:[code]<?php$separated = explode("\\", $word);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24857-explode-function-question/#findComment-113288 Share on other sites More sharing options...
wildteen88 Posted October 23, 2006 Share Posted October 23, 2006 Use two backslashes instead:$separated = explode("\\", $word);if you use one backslash on its own PHP will think you;re escaping the closing double quote. Use two backslashes together (\\) prevents this. Quote Link to comment https://forums.phpfreaks.com/topic/24857-explode-function-question/#findComment-113289 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.