oracle259 Posted October 20, 2006 Share Posted October 20, 2006 How can i modify the code below to allow me better control the combination.eg i select $combine = 1 gives $string3 = 1524334251 $combine = 2 gives $string3 = 125344213...$combine = 3 gives $string3 = 123545....[code]<?php$string1 = "12345";$string2 = "54321";$string3 = '';for($i=0;$i<strlen($string1);$i++) $string3 .= $string1[$i] . $string2[$i];echo $string3;?>[/code] Quote Link to comment Share on other sites More sharing options...
akitchin Posted October 20, 2006 Share Posted October 20, 2006 well, $string1 is not an array, so $string1[$i] will not work. to specify a particular character within a string, use curly braces after the variable, not square brackets:[code]for($i=0;$i<strlen($string1);$i++) $string3 .= $string1{$i} . $string2{$i};[/code] Quote Link to comment 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.