How do I concatenate 2 or more string variables to 1 and then again split the 1 string variable into 2 or more?
2 1344
Quite simple. Concentrating strings is easy as smushing them together. As far as splitting them, you can use many options. Here's some examples: -
<?php
-
-
// First off, we smush $foo and $bar together using a . between them:
-
$foo = "Hello";
-
$bar = "World!";
-
-
$foobar = $foo.$bar; // Returns: HelloWorld;
-
$spacebar = $foo.' '.$bar; // Returns: Hello World! (With a space)
-
$dashbar = $foo.'-'.$bar; // Returns: Hello-World!
-
// And we can go on forever... Moving on
-
-
// Now, we can separate strings by a delimiter using explode();
-
$foobar = "Hello World!";
-
list($foo, $bar) = explode(" ", $foobar);
-
// $foo is now "Hello" and $bar is now "World!"
-
// Though, explode() will separate every space ever, and since our list doesn't have enough strings to hold it, stuff will vanish. You can also separate by substr();
-
-
$foobar = "Hello World!";
-
$foo = substr($foobar, 0, 5); // Sets $foo equal to the first five characters, starting on character 0 and ending on 5.
-
$bar = substr($foobar, 6, 12); // And sets $bar equal to characters 6 through 12, making it "World!"
-
And these are only a few ways to split up strings. I also suggest browsing php.net for the string functions. Also, if you can post specifically what you would like to do, I'm sure there's a method that'll work nicely.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dim |
last post by:
I found that C# has some buggy ways to process string across methods.
I have a class with on global string var and a method where i add / remove
from this string
Consider it a buffer... with some...
|
by: tshad |
last post by:
Can you do a search for more that one string in another string?
Something like:
someString.IndexOf("something1","something2","something3",0)
or would you have to do something like:
if...
|
by: zoro |
last post by:
Hi,
I am new to C#, coming from Delphi. In Delphi, I am using a 3rd party
string handling library that includes some very useful string
functions, in particular I'm interested in BEFORE (return...
|
by: WaterWalk |
last post by:
Hello, I'm currently learning string manipulation. I'm curious about
what is the favored way for string manipulation in C, expecially when
strings contain non-ASCII characters. For example, if...
|
by: micklee74 |
last post by:
hi
if i have a some lines like this
a ) "here is first string"
b ) "here is string2"
c ) "here is string3"
When i specify i only want to print the lines that contains "string" ie
the first...
|
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 ...
|
by: crprajan |
last post by:
String Manipulation: Given a string like “This is a string”, I want to remove all single characters( alphabets and numerals) like (a, b, 1, 2, .. ) .
So the output of the string will be “This is...
|
by: Frinavale |
last post by:
I currently have a .NET application that has an object which passes a string (a connection string) as a parameter to another object that does database manipulation.
This string isn't stored...
|
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...
|
by: mann_mathann |
last post by:
can anyone tell me a solution:
i cannot use the features in standard c++ string classgh i included
the string.h file but still its not working.
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |