473,396 Members | 1,917 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,396 software developers and data experts.

String manipulation (PHP explode() like function)

Hello,

If I have a string "abc.def.ghi"

Is there any simple way to explode it to an array like PHP explode()
function?

Like this:

/* This is not C# code */
string Data = "abc.def.ghi";
string[] Ret = explode(Data);

/* Ret will contain:
Ret[0] = "abc"
Ret[1] = "def"
Ret[2] = "ghi"
So that I can reverse the string easily */

Actually, I want to change the string "abc.def.ghi" to "ghi.def.abc"
Nov 16 '05 #1
1 22234
using the "Split" method of "String" class:

string test = "abc.def.ghi";

string [] result = test.Split(new Char[] {'.'});

for (int i = 0; i < result.Length; i++)

{

Console.WriteLine(result[i]);

}
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"FrzzMan" <Fr***************@vnOCzone.com> wrote in message
news:OB**************@TK2MSFTNGP11.phx.gbl...
Hello,

If I have a string "abc.def.ghi"

Is there any simple way to explode it to an array like PHP explode()
function?

Like this:

/* This is not C# code */
string Data = "abc.def.ghi";
string[] Ret = explode(Data);

/* Ret will contain:
Ret[0] = "abc"
Ret[1] = "def"
Ret[2] = "ghi"
So that I can reverse the string easily */

Actually, I want to change the string "abc.def.ghi" to "ghi.def.abc"

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: William Krick | last post by:
I have a string containing concatenated ascii "records" that are each terminated by '\n'. For testing purposes, I construct sample data like this... $mystring =...
9
by: Rune | last post by:
Is it best to use double quotes and let PHP expand variables inside strings, or is it faster to do the string manipulation yourself manually? Which is quicker? 1) $insert = 'To Be';...
5
by: Cleverbum | last post by:
I'm not really accustomed to string manipulation and so I was wondering if any of you could be any help i speeding up this script intended to change the format of some saved log information into a...
5
by: Niyazi | last post by:
Hi, Does anyone knows any good code for string manipulation similar to RegularExpresion? I might get a value as string in a different format. Example: 20/02/2006 or 20,02,2006 or ...
6
by: kellygreer1 | last post by:
What is a good one line method for doing a "length safe" String.Substring? The VB classes offer up the old Left function so that string s = Microsoft.VisualBasic.Left("kelly",200) // s will =...
3
by: frankeljw | last post by:
I have 2 Java strings 1st String is a series of names, colons, and numbers ie) Name1:13:Name2:4526:Name3:789:Name4:3729:Name5:6:Name6:44 2nd String is a name ie) Name2 I need to get the...
1
by: 848lu | last post by:
PHP - display from txt file with explode function hi, i am trying to display all data from a txt file with a function of explode but does not work..... <? #reads a text file outputs it to...
0
by: pazazuzu | last post by:
Hi everyone, I currently have an assignment which I am almost done with but am having problems trying to figure out how to integrate a string function search. I have a text box called...
1
by: pazazuzu | last post by:
Hello, I have been having problems with some code I am writing and have not been able to figure out what I am doing wrong, even after some debugging. I have a textbox that users can input any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.