AHA7 Posted April 28, 2007 Share Posted April 28, 2007 Hello, What did I do wrong: for($i=1; $i<=5; $i++) { ${string2.$i} = explode("\"", $string1); } for($i=1; $i<=5; $i++) { echo ${relLink.$i}[0]; } Quote Link to comment https://forums.phpfreaks.com/topic/49021-solved-whats-wrong-in-this-code-help-please/ Share on other sites More sharing options...
Psycho Posted April 28, 2007 Share Posted April 28, 2007 Well, I have no idea what you are trying to do in these two instances. I have never seen any code like that: ${string2.$i} ${relLink.$i}[0] But, you also have a syntax error in the explode function - one too many quote marks. Quote Link to comment https://forums.phpfreaks.com/topic/49021-solved-whats-wrong-in-this-code-help-please/#findComment-240147 Share on other sites More sharing options...
AHA7 Posted April 28, 2007 Author Share Posted April 28, 2007 Well, I have no idea what you are trying to do in these two instances. I have never seen any code like that: ${string2.$i} ${string2.$i}[0] (Corrected) But, you also have a syntax error in the explode function - one too many quote marks. If $i =0 then ${string2.$i} would be $string20, and ${string2.$i}[0] would be $string20[0]. What's the syntax error in the explode function. I want to split $string1 into strings bounded by double quote marks. the backslash is an escape char. Quote Link to comment https://forums.phpfreaks.com/topic/49021-solved-whats-wrong-in-this-code-help-please/#findComment-240152 Share on other sites More sharing options...
Silverado_NL Posted April 28, 2007 Share Posted April 28, 2007 for($i=1; $i<=5; $i++) { ${string2.$i} = explode("\"", $string1); } for($i=1; $i<=5; $i++) { echo ${relLink.$i}[0]; } there is no "FOR" loop needed, to use the explode function. The explode function outputs its data into an array. Here is what i would do <?php $string1 = 'these\are\exploded\like\followed'; $string_array = explode("\\", $string1); //NOTICE the "\\"???? The first \ (Backward slash) functions as an escape character for the second one print_r($string_array); echo "<br>First array numbered 0 contains:<b><font size=6>"; echo $string_array[0]; echo "</font></b><br>Second array numbered 1 contains:<b><font size=6>"; echo $string_array[1]; echo "</font></b><br>Third array numbered 2 contains:<b><font size=6>"; echo $string_array[2]; echo "</font></b><br><font size=6>etc....<font>"; ?> the print function just shows the content of an array. i always look at the array in the source code of the output page. you will have a much better overview. or you can call the array's information by specifying the array number like this $arrayvariable[number] hope this help Greetz Silverado Quote Link to comment https://forums.phpfreaks.com/topic/49021-solved-whats-wrong-in-this-code-help-please/#findComment-240161 Share on other sites More sharing options...
AHA7 Posted April 28, 2007 Author Share Posted April 28, 2007 OK, in a way or another my problem is now solved! Thanks all for your replies! Quote Link to comment https://forums.phpfreaks.com/topic/49021-solved-whats-wrong-in-this-code-help-please/#findComment-240168 Share on other sites More sharing options...
MadTechie Posted April 28, 2007 Share Posted April 28, 2007 please click solved Quote Link to comment https://forums.phpfreaks.com/topic/49021-solved-whats-wrong-in-this-code-help-please/#findComment-240171 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.