canadabeeau Posted March 14, 2010 Share Posted March 14, 2010 Hi again, I have some code which splits a string at a delimeter $images = explode(";", $images); Now this code then loops and alters as necessary for ($i = 0, $len = strlen($images); $i < $len; $i++) { echo 'AAA'.$images{$i}; } The only problem is after the last array it adds two sets of AAA (so AAAAAA) how can I stop it doing this? $images = image1.jpg;image2.jpg Link to comment https://forums.phpfreaks.com/topic/195184-explode/ Share on other sites More sharing options...
canadabeeau Posted March 14, 2010 Author Share Posted March 14, 2010 sorry it is adding three sets of AAA Link to comment https://forums.phpfreaks.com/topic/195184-explode/#findComment-1025874 Share on other sites More sharing options...
canadabeeau Posted March 14, 2010 Author Share Posted March 14, 2010 I am unsure where to start in regards to fixing this problem Link to comment https://forums.phpfreaks.com/topic/195184-explode/#findComment-1025879 Share on other sites More sharing options...
wildteen88 Posted March 14, 2010 Share Posted March 14, 2010 Are you wanting to change the delimiter, in your case a semi-colon into the string 'AAA'? In that case you could just use str_replace. Eg $images = str_replace(";", "AAA", $images); Link to comment https://forums.phpfreaks.com/topic/195184-explode/#findComment-1025897 Share on other sites More sharing options...
DaiLaughing Posted March 14, 2010 Share Posted March 14, 2010 Use a foreach loop instead of for? Link to comment https://forums.phpfreaks.com/topic/195184-explode/#findComment-1025904 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.