Welcome Guest, Not a member yet? Register   Sign In
Parse HTML table data and insert_batch effectively?
#2

[eluser]CroNiX[/eluser]
I wouldn't worry about sending the keys. That would double the bytes needed to transfer anyway. But try just sending the values array and do something like this:

Code:
$keys = array('name', 'age', 'random');

$values = '[["Juan","23","1990"],["Jonhatan","25","1980"],["Pete","20","1991"]]'; //This would be coming from your ajax
$values = json_decode($values);

foreach($values as $c => $subarr)
{
$values[$c] = array_combine($keys, $subarr);
}

print_r($values);

Code:
Array
(
    [0] => Array
        (
            [name] => Juan
            [age] => 23
            [random] => 1990
        )

    [1] => Array
        (
            [name] => Jonhatan
            [age] => 25
            [random] => 1980
        )

    [2] => Array
        (
            [name] => Pete
            [age] => 20
            [random] => 1991
        )
)

Probably not exactly what you wanted, but best I could think of in a few minutes. Smile


Messages In This Thread
Parse HTML table data and insert_batch effectively? - by El Forum - 08-19-2014, 07:09 PM
Parse HTML table data and insert_batch effectively? - by El Forum - 08-19-2014, 08:12 PM
Parse HTML table data and insert_batch effectively? - by El Forum - 08-20-2014, 05:08 AM
Parse HTML table data and insert_batch effectively? - by El Forum - 08-20-2014, 08:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB