473,406 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

explode the / variable

190 100+
Hi ,

i have the variable $path="root/sample";

i want to explode this variable by /, but while using

explode("/",$path);

i got parse error, how we can do this
Mar 31 '09 #1
5 2475
I have 2 ideas what can cause it.

1. you don't assign explode into variable, namely array
Expand|Select|Wrap|Line Numbers
  1. $path="root/sample";
  2. $dirs = explode( "/", $path);
  3. // $dirs[0] = "root", $dirs[1] = "sample";
  4.  

2. Your separator is a special character, you need to comment it with backslash
Expand|Select|Wrap|Line Numbers
  1. $dirs = explode( "\\", $path);
  2.  
Mar 31 '09 #2
Nert
64
@maheswaran
i tried to use your code and it works fine to me.
Expand|Select|Wrap|Line Numbers
  1. $path="root/sample";
  2. $dir = explode("/",$path);
  3. echo $dir[0];
  4. echo $dir[1];
  5.  
Apr 1 '09 #3
maheswaran
190 100+
Yes guys,

It is not work in my system. So that am confused.....
Apr 1 '09 #4
Nert
64
@maheswaran
Have you tried using a different separator? instead of using "/" try the other character to test whether the problem is really on your system or just on the codes.
Apr 1 '09 #5
maheswaran
190 100+
ya will do and let you know
Apr 1 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: frizzle | last post by:
Hi there, i have a site with fake folders & files. htaccess rewrites everything to index.php?vars now in index.php i decide what file to include with a switch/case statement. to define where...
5
by: FFMG | last post by:
Hi, I need the php equivalent of explode in one of my app. I read a very big file and "explode" each line to fill a structure. The reading of the file, 19Mb, (I will also need to streamline...
0
by: k04jg02 | last post by:
Python has a nifty operator that will take a container and pass its elements as function parameters. In Python you can make a list like so: x = Then you can say: f(*x)
2
tolkienarda
by: tolkienarda | last post by:
hi everyone i am getting a bunch of values from a form via post all of the information that this question deals with is from series of check boxes below is the code that creates the check boxes...
0
by: Orin | last post by:
Hi, Here is my task: - need to get text from a template variable. For example we have a text with templates "Cars" and "Producers": "{{Cars|Toyota=blablabla |Moskvitch=blablabla...
3
by: lbvox | last post by:
Hello, I have created this script, but I do not succeed to insert the function "explode ()" for being able to gain given following dates ---- ($host="hostname" / $msg="msg" /$date="date") <?php...
5
by: sathyashrayan | last post by:
Dear group, The function to be used as follows: $links = "http://www.campaignindia.in/feature/analysis"; $tag1 = '<div class=feature-wrapper>'; $tag2 = '<h1><a href'; $tag3 = "</a>"; $op =...
8
by: vinpkl | last post by:
hi all i want to use explode url for shotening my urls i have a url like http://localhost/vineet/products.php?dealer_id=12&category_id=2 This is my navigation php code that has url...
4
by: phpnewbie26 | last post by:
So my goal is actually to use the in_array function but I believe it searches for a string within an array. My problem is that I explode a line and my data is now in an array. I'm hoping to change...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.