Hi,
I have 2 String
String1 = 1234
String2 = 6789
I need to return the string but mixed eg:
string returned: 16273849
Any suggestions? 8 1405
On Mar 5, 3:04 pm, AlejandroArias <jalejandro0...@gmail.comwrote:
Hi,
I have 2 String
String1 = 1234
String2 = 6789
I need to return the string but mixed eg:
string returned: 16273849
Any suggestions?
So you want a string that has all those characters in it but
randomized? Just concatenate them then randomize it:
$str1 = "1234";
$str2 = "6789";
$str3 = $str1 . $str2;
$str4 = str_shuffle($str3);
On Wed, 05 Mar 2008 21:04:19 +0100, AlejandroArias
<ja************@gmail.comwrote:
Hi,
I have 2 String
String1 = 1234
String2 = 6789
I need to return the string but mixed eg:
string returned: 16273849
<?php
$string1 = '1234';
$string2 = '6789';
$length = strlen($string1) strlen($string2) ? strlen($string1) :
strlen($string2);
$newstring = '';
for($i = 0; $i < $length; $i++){
if(isset($string1{$i})) $newstring .= $string1{$i};
if(isset($string2{$i})) $newstring .= $string2{$i};
}
echo $newstring;
?>
--
Rik Wasmus
On 5 mar, 15:46, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
On Wed, 05 Mar 2008 21:04:19 +0100, AlejandroArias
<jalejandro0...@gmail.comwrote:
Hi,
I have 2 String
String1 = 1234
String2 = 6789
I need to return the string but mixed eg:
string returned: 16273849
<?php
$string1 = '1234';
$string2 = '6789';
$length = strlen($string1) strlen($string2) ? strlen($string1) :
strlen($string2);
$newstring = '';
for($i = 0; $i < $length; $i++){
if(isset($string1{$i})) $newstring .= $string1{$i};
if(isset($string2{$i})) $newstring .= $string2{$i};}
echo $newstring;
?>
--
Rik Wasmus
tkx Rik great work
..oO(Rik Wasmus)
><?php $string1 = '1234'; $string2 = '6789'; $length = strlen($string1) strlen($string2) ? strlen($string1) : strlen($string2);
$length = max(strlen($string1), strlen($string2));
>$newstring = ''; for($i = 0; $i < $length; $i++){
if(isset($string1{$i})) $newstring .= $string1{$i};
if(isset($string2{$i})) $newstring .= $string2{$i}; } echo $newstring; ?>
Curly braces for accessing single characters are deprecated (or at least
will be in PHP 6). Array syntax [] is recommended.
Micha
On Thu, 06 Mar 2008 00:47:29 +0100, Michael Fesser <ne*****@gmx.dewrote:
.oO(Rik Wasmus)
><?php $string1 = '1234'; $string2 = '6789'; $length = strlen($string1) strlen($string2) ? strlen($string1) : strlen($string2);
$length = max(strlen($string1), strlen($string2));
Would be better indeed.
>$newstring = ''; for($i = 0; $i < $length; $i++){ if(isset($string1{$i})) $newstring .= $string1{$i}; if(isset($string2{$i})) $newstring .= $string2{$i}; } echo $newstring; ?>
Curly braces for accessing single characters are deprecated (or at least
will be in PHP 6). Array syntax [] is recommended.
He, keep forgetting which is preferred. I'll try to remember this time :)
--
Rik Wasmus
Michael Fesser wrote:
.oO(Rik Wasmus)
><?php $string1 = '1234'; $string2 = '6789'; $length = strlen($string1) strlen($string2) ? strlen($string1) : strlen($string2);
$length = max(strlen($string1), strlen($string2));
>$newstring = ''; for($i = 0; $i < $length; $i++){ if(isset($string1{$i})) $newstring .= $string1{$i}; if(isset($string2{$i})) $newstring .= $string2{$i}; } echo $newstring; ?>
Curly braces for accessing single characters are deprecated (or at least
will be in PHP 6). Array syntax [] is recommended.
Good to know this. And I thought I was doing it incorrectly (or
deprecated) with [] :)
On Mar 5, 12:04 pm, AlejandroArias <jalejandro0...@gmail.comwrote:
Hi,
I have 2 String
String1 = 1234
String2 = 6789
I need to return the string but mixed eg:
string returned: 16273849
Any suggestions?
try:
$String1 = 1234
$string1 .= 5678
echo $string1;
On Thu, 06 Mar 2008 22:00:25 +0100, floydiology <jo**********@gmail.com>
wrote:
On Mar 5, 12:04 pm, AlejandroArias <jalejandro0...@gmail.comwrote:
>Hi,
I have 2 String
String1 = 1234 String2 = 6789
I need to return the string but mixed eg:
string returned: 16273849
Any suggestions?
try:
$String1 = 1234
$string1 .= 5678
echo $string1;
Which will result in:
5678
Doesn't seem close to what the OP wants, even if I repair the case of the
variable name.
--
Rik Wasmus This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: MADS |
last post by:
Hi, I have a SQL Server for a SAP database with the collation
SQL_Latin1_General_CP850_BIN. When I connect to that server (or, in
this example, to another server with the...
|
by: Nanchil |
last post by:
Hi,
We created a database (DB2 UDB 7.2 on solaris 8) without this
(COLLATE USING IDENTITY ) option. But we need this now for binary
sorting. The database is siebel database. Is it possible to drop...
|
by: Dag Henriksson |
last post by:
I'm trying to compare strings written in Swedish using:
std::locale loc(""); // System locale is Swedish
loc(first, second);
But this does not give me the right return value.
for example,
...
|
by: Francisco Araujo |
last post by:
I don't know if this is a bug or if i'm doing something wrong, but
when the print dialog is shown on VB.NET and the user select
multiple-copies and check the collate option and click ok, the...
|
by: Robert Liles |
last post by:
I am using Visual Basic.NET 2002 and cannot get "collate" from the
PrintDialog1 or e.PageSettings.PrinterSettings.Collate to return anything
but "False." What am I doing wrong?
I am using...
|
by: Robert Liles |
last post by:
If I check the "Collate" box in the PrintDialog it is ignored, always
returns "False" and does not collate. If I add the line
" e.PageSettings.PrinterSettings.Collate = True"
in my print routine,...
|
by: Zengfa Gao |
last post by:
Hi, all:
I have a schema definition, worked fine for PostgreSQL
7.2 and 7.3. But I saw errors when I use it on
PostgreSQL 7.4.
Can anyone tell me what's changed in 7.4?
Thanks a lot!
|
by: Ron Adam |
last post by:
I've made a few more changes to my little collate module.
There might be better ways to handle the options, or better choices for the
options themselves. I tried to keep it as general as...
|
by: mabubakarpk |
last post by:
HI.
I am using SQL Server 2000. I generate a script of some table from EmpDB database when I run script in query analyzer it return error "Incorrect syntax near 'COLLATE'."
Scripts is
...
|
by: baburk |
last post by:
CREATE TABLE Employees(
EmployeeID int IDENTITY(1,1) NOT NULL,
LastName nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL)
What is use of Collate.
In what are all the places can we...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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,...
| |