Archimedees Posted October 10, 2007 Share Posted October 10, 2007 Is it possible to have the results of an exploded string into 4 different arrays?? I have many lines of $strPingCurrentLine each containing url, email size and command details. I therefore hope for a way to push each exploded $strPingCurrentLine into $arUrl = array(); $arEmail = array(); $arSize = array(); $arCommand = array(); Instead of for instance $arTemp = explode("\t", $strPingCurrentLine); Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/72629-solved-exploding-a-string/ Share on other sites More sharing options...
lessthanthree Posted October 10, 2007 Share Posted October 10, 2007 list($arUrl[], $arEmail[], $arSize[], $arCommand[]) = explode("\t", $strPingCurrentLine); Quote Link to comment https://forums.phpfreaks.com/topic/72629-solved-exploding-a-string/#findComment-366193 Share on other sites More sharing options...
Archimedees Posted October 11, 2007 Author Share Posted October 11, 2007 Thanks mate. Only realised this won't bring me where I want to get. Quote Link to comment https://forums.phpfreaks.com/topic/72629-solved-exploding-a-string/#findComment-366908 Share on other sites More sharing options...
Orio Posted October 11, 2007 Share Posted October 11, 2007 Can you show a part of this big string? If the format is something like this: url (tab) email (tab) size (tab) command (tab) url (tab) email (tab) ... Then you could do something like this: <?php $parts = explode("\t", $strPingCurrentLine); $size = count($parts); $temp = array(); $temp[0] = array(); $temp[1] = array(); $temp[2] = array(); $temp[3] = array(); for($i=0; $i<$size; $i++) $temp[$i%4][] = $parts[$i]; $arUrl = $temp[0]; $arEmail = $temp[1]; $arSize = $temp[2]; $arCommand = $temp[3]; unlink($temp); //free some memory... ?> Orio. Quote Link to comment https://forums.phpfreaks.com/topic/72629-solved-exploding-a-string/#findComment-366943 Share on other sites More sharing options...
Archimedees Posted October 11, 2007 Author Share Posted October 11, 2007 I did exactly that. How did you Know? UTelepathic? It worked. Quote Link to comment https://forums.phpfreaks.com/topic/72629-solved-exploding-a-string/#findComment-367008 Share on other sites More sharing options...
Orio Posted October 11, 2007 Share Posted October 11, 2007 lol No, I am not telepathic, it just made sense by how you explained Glad it helped. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/72629-solved-exploding-a-string/#findComment-367028 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.