小编PiK*_*Key的帖子

阵列结构为Array的字符串

我有字符串:

Main.Sub.SubOfSub
Run Code Online (Sandbox Code Playgroud)

某种数据,可能是一个字符串:

SuperData
Run Code Online (Sandbox Code Playgroud)

我怎样才能将它全部转换为上面的数组?

Array
(
[Main] => Array
    (
        [Sub] => Array
            (
                [SubOfSub] => SuperData
            )

    )
Run Code Online (Sandbox Code Playgroud)

)

感谢您的帮助,PK

php arrays string algorithm multidimensional-array

7
推荐指数
2
解决办法
2504
查看次数

表格中的HTML表格不会通过POST发送所有可用数据

我有一个113行的表.每行有9个单元格,其中有一个输入,就像这个shema:

row_1[td_1],row_1[td_2],[...],
row_2[td_1],row_2[td_2],[...],
row_3[td_1],row_3[td_2],[...]
[...]
row_113[td_1],row_113[td_2],[...]
Run Code Online (Sandbox Code Playgroud)

问题:当我通过POST发送这些数据时,我只获取数据到row_112的第一个字段:

[...]  
["row_111"]=>
  array(9) {
    ["tytul"]=>
    string(15) "example element"
    ["pkwiu"]=>
    string(0) ""
    ["jm"]=>
    string(1) "2"
    ["ilosc"]=>
    string(1) "1"
    ["cena_brutto"]=>
    string(5) "74.00"
    ["vat"]=>
    string(3) "23%"
    ["vat_oryginalny"]=>
    string(2) "23"
    ["cena_netto"]=>
    string(5) "60.16"
    ["wartosc_brutto"]=>
    string(5) "74.00"
  }
  ["row_112"]=>
  array(1) {
    ["tytul"]=>
    string(15) "example element" <------
  }
Run Code Online (Sandbox Code Playgroud)

为什么我没有收到完整的表单数据?

这个例子可以在这里找到:http: //pastebin.com/ahVqUetJ

在脚本之上我简单地说:

<?php
    if(isset($_POST) && count($_POST) > 0) {
        var_dump($_POST);
        exit;
    }
?>
Run Code Online (Sandbox Code Playgroud)

php post

3
推荐指数
1
解决办法
812
查看次数

Golang concurrency write to variable - why this code works?

I'm learning concurrency-related issues in Golang. I wrote some code:

package main

import (
    "fmt"
    "time"
)

func incr(num *int) {
    *num = *num + 1

}

func main() {
    var a = 0

    for i := 0; i < 50; i++ {
        go incr(&a)
    }

    incr(&a)

    time.Sleep(1 * time.Second)
    fmt.Println(a)
}
Run Code Online (Sandbox Code Playgroud)

The result of this code is: 51

In this code I've declared a variable which I'm increasing in 50 running goroutines. What I've read and unsterstood this code …

concurrency mutex locking shared-memory go

-4
推荐指数
1
解决办法
86
查看次数