Jump to content

[SOLVED] exploding a string


Archimedees

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.