Jump to content

Recommended Posts

 

 

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.

Link to comment
https://forums.phpfreaks.com/topic/72629-solved-exploding-a-string/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.