I have a string:
Some text1 Info about text1 Numbers about text1
Some text2 Info about text2 Numbers about text2
Some text3 Info about text3 Numbers about text3
Every line is of course ending with a
, and every text bit is separated with a \t
. This is something I cannot change.
i.e. Some text1\tInfo about text1\tNumbers about text1
The string comes via a $_POST() and I then want to explode this so that i can save each part of each line in my DB.
My code:
$sigs = $_POST['allSigInput'];
$strings = explode ("
", $sigs);
$sigCount = count($strings);
var_dump($strings);
foreach($strings as $string) {
for($c=0; $c<=$sigCount; $c++) {
${'sigArr_'.$c} = explode ("\t", $string);
}
}
This explodes the string just fine but var_dump(); for all $sigArr_# are the same, and the last array saved.
So all 3 outputs are the same:
array (size=3)
0 => string 'Some Text3'
1 => string 'Info about text3'
2 => string 'Numbers about text3'
I would of course like the 3 arrays to contain info respectively to each line of text and be exploded so every bit of text separated by \t
, is in an array.