0

私はこれを持っています

    <?php 
    if(isset($_GET['datos'])){
        $xd = $_GET['datos'];

       $datosCompletos = explode(',', $xd);
       $longArreglo = count($datosCompletos);

       for ($i=0; $i < $longArreglo; $i++) { 
            $arregloInformacion = explode('|', $datosCompletos[$i]);

        $longInformacion = count($arregloInformacion);
        $dato = "dato".$i; 
        for ($u=0; $u < $longInformacion; $u++) {
            $dato[$u] = $arregloInformacion[$u];
            echo $dato[$u];

        }
   }
}
?>

これは私が送ったデータです。 H|341.45|6305|276|153|673.4|7407.4|1185.18|8592.58|8674.75,Sria.plan.fnzas|Tesoreria|1538|Rodriguez%20Guzman%20Noemi|58|2011-05-01|0000188A|T|タイトル| 1998-12-16|1994-07-09|M|1083.78|20841|276|153|2127|23397|3743.52|27140.5|27222.7,Sria.plan.fnzas|Tesoreria|1500|Martinez%20Rodriguez%20Edith|23| 2013-05-01|0000188C|B|ヒジャ|1989-07-25|2006-04-16|M|438.62|8208|276|153|863.7|9500.7|1520.11|11020.8|11103

私は入る必要があります

$dato0[0] = Sria.plan
$dato0[1] = Fnzas
$dato0[2] = 139
$dato0[3] = ... //etc

$dato1[0] = Sria.plan.fnzas
$dato1[1] = Tesoreria
$dato1[2] = 1538
$dato1[3] = ... //etc

$dato2[0] = Sria.plan.fnzas
$dato2[1] = Tesoreria
$dato2[2] = 1500
$dato2[3] = ... //etc

しかし、このコードを分析すると、SF1L220TT12H362167188ST1R520TT11M122122322ST1M220BH12M482189111

どうして?!

4

6 に答える 6

1

可変変数を使用するには、次の値を 2 倍にする必要があります$

$$dato[$u] = $arregloInformacion[$u];

"dato".$iしかし、なぜ異なる変数でそれをやっているのですか? 多次元配列を使用しないのはなぜですか。

$dato[$i] = $arregloInformacion;
于 2013-11-14T06:16:11.377 に答える
0

これは機能します

  <?php
  $_GET['datos']="Sria.plan|Fnzas|139|Lopez%20Portillo%20Alcantara%20Jorge%20Ernesto|29|2013-05-01|0000188B|T|Titular|1984-03-19|2011-07-16|H|341.45|6305|276|153|673.4|7407.4|1185.18|8592.58|8674.75,Sria.plan.fnzas|Tesoreria|1538|Rodriguez%20Guzman%20Noemi|58|2011-05-01|0000188A|T|Titular|1998-12-16|1994-07-09|M|1083.78|20841|276|153|2127|23397|3743.52|27140.5|27222.7,Sria.plan.fnzas|Tesoreria|1500|Martinez%20Rodriguez%20Edith|23|2013-05-01|0000188C|B|Hija|1989-07-25|2006-04-16|M|438.62|8208|276|153|863.7|9500.7|1520.11|11020.8|11103";

  if (isset($_GET['datos']))
  {
     $xd = $_GET['datos'];
     $datosCompletos = explode(',', $xd);
     $longArreglo    = count($datosCompletos);

     for ($i = 0; $i < $longArreglo; $i++)
     {
        $arregloInformacion = explode('|', $datosCompletos[$i]);

        $longInformacion = count($arregloInformacion);
        $dato            = "dato" . $i;
        for ($u = 0; $u < $longInformacion; $u++)
        {
           $tmp=$$dato;
           $tmp[$u] = $arregloInformacion[$u];
           $$dato=$tmp;
        }
     }
        var_dump($dato0[0]);
        var_dump($dato0[1]);
        var_dump($dato0[2]);

        var_dump($dato1[0]);
        var_dump($dato1[1]);
        var_dump($dato1[2]);
  }
  ?>
于 2013-11-14T06:43:34.697 に答える
0

コードを100%テスト済みのこのコードに置き換えるだけです

<?php
$xd = 'Sria.plan|Fnzas|139|Lopez%20Portillo%20Alcantara%20Jorge%20Ernesto|29|2013-05-01|0000188B|T|Titular|1984-03-19|2011-07-16|H|341.45|6305|276|153|673.4|7407.4|1185.18|8592.58|8674.75,Sria.plan.fnzas|Tesoreria|1538|Rodriguez%20Guzman%20Noemi|58|2011-05-01|0000188A|T|Titular|1998-12-16|1994-07-09|M|1083.78|20841|276|153|2127|23397|3743.52|27140.5|27222.7,Sria.plan.fnzas|Tesoreria|1500|Martinez%20Rodriguez%20Edith|23|2013-05-01|0000188C|B|Hija|1989-07-25|2006-04-16|M|438.62|8208|276|153|863.7|9500.7|1520.11|11020.8|11103';
$datosCompletos = explode(',', $xd);
$longArreglo = count($datosCompletos);

for ($i = 0; $i < $longArreglo; $i++) {
    $arregloInformacion = explode('|', $datosCompletos[$i]);
    $longInformacion = count($arregloInformacion);
    $dato = "dato" . $i;
    for ($u = 0; $u < $longInformacion; $u++) {
        $final_array[$dato][$u] = $arregloInformacion[$u];
    }
}
echo "<pre>";
print_r($final_array);
?>

出力は

Array
(
    [dato0] => Array
        (
            [0] => Sria.plan
            [1] => Fnzas
            [2] => 139
            [3] => Lopez%20Portillo%20Alcantara%20Jorge%20Ernesto
            [4] => 29
            [5] => 2013-05-01
            [6] => 0000188B
            [7] => T
            [8] => Titular
            [9] => 1984-03-19
            [10] => 2011-07-16
            [11] => H
            [12] => 341.45
            [13] => 6305
            [14] => 276
            [15] => 153
            [16] => 673.4
            [17] => 7407.4
            [18] => 1185.18
            [19] => 8592.58
            [20] => 8674.75
        )

    [dato1] => Array
        (
            [0] => Sria.plan.fnzas
            [1] => Tesoreria
            [2] => 1538
            [3] => Rodriguez%20Guzman%20Noemi
            [4] => 58
            [5] => 2011-05-01
            [6] => 0000188A
            [7] => T
            [8] => Titular
            [9] => 1998-12-16
            [10] => 1994-07-09
            [11] => M
            [12] => 1083.78
            [13] => 20841
            [14] => 276
            [15] => 153
            [16] => 2127
            [17] => 23397
            [18] => 3743.52
            [19] => 27140.5
            [20] => 27222.7
        )

    [dato2] => Array
        (
            [0] => Sria.plan.fnzas
            [1] => Tesoreria
            [2] => 1500
            [3] => Martinez%20Rodriguez%20Edith
            [4] => 23
            [5] => 2013-05-01
            [6] => 0000188C
            [7] => B
            [8] => Hija
            [9] => 1989-07-25
            [10] => 2006-04-16
            [11] => M
            [12] => 438.62
            [13] => 8208
            [14] => 276
            [15] => 153
            [16] => 863.7
            [17] => 9500.7
            [18] => 1520.11
            [19] => 11020.8
            [20] => 11103
        )

)
于 2013-11-14T06:30:43.177 に答える
0
<?php 
if(isset($_GET['datos'])){
  $outerArr = explode(',', $_GET['datos']);
  foreach ($outerArr as $items) {
    $data = explode('|', $items);
    $i = 0;
    foreach ($data as $dato) {
      $datos[$i] = $dato;
      echo $datos[$i];
      $i++;
    }
  }
}
?>

実行しませんでした。

于 2013-11-14T06:23:28.357 に答える