search value (with regex) in array and push search value to multidimensional array in PHP

Example Data

Array
(
    [0] => [DATA_1_A]
    [1] => [DATA_1_B] [DATA_2_B]
    [2] => [DATA_1_C] [DATA_2_C] [DATA_3_C]
)

And push value to multidimensional array.

Array
(
    [0] => Array
        (
            [0] => DATA_1_A
        )
    [1] => Array
        (
            [0] => DATA_1_B
            [1] => DATA_2_B
        )
    [2] => Array
        (
            [0] => DATA_1_C
            [1] => DATA_2_C
            [2] => DATA_3_C
        )
)

$new = array_map(function($i) {
if(preg_match_all('/\[([^\]]+)\]/', $i, $m)) return $m[1];
return $i; }, $arr);

http://stackoverflow.com/a/37666969

Answer:How to print all information from an HTTP request to the screen, in PHP

echo file_get_contents( 'php://input' );

http://stackoverflow.com/a/3136304
ref: https://twitter.com/sornram9254/status/738058662141263872

Answer:Remove empty array elements (PHP)

$emptyRemoved = array_filter($linksArray);

http://stackoverflow.com/a/3654335
ref: https://twitter.com/sornram9254/status/737673183155740672

Answer:Rebase array keys after unsetting elements [php]

$array = array_values($array);

http://stackoverflow.com/a/5943165
ref: https://twitter.com/sornram9254/status/737696350146437120

Answer:Detecting request type in PHP (GET, POST, PUT or DELETE)

$_SERVER['REQUEST_METHOD']

http://stackoverflow.com/a/359050
ref: https://twitter.com/sornram9254/status/738063120422174720

Answer:How to post data in PHP using file_get_contents?

$postdata = http_build_query(
array(
‘var1’ => ‘some content’,
‘var2’ => ‘doh’
)
);
$opts = array(‘http’ =>
array(
‘method’ => ‘POST’,
‘header’ => ‘Content-type: application/x-www-form-urlencoded’,
‘content’ => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents(‘http://example.com/submit.php’, false, $context);


http://stackoverflow.com/a/2445332

AJAX jQuery PHP Return Value

data.php

echo json_encode($myArray);

display.php

$.ajax({ url: ‘/my/site’,
data: {action: ‘test’},
dataType: ‘json’,
type: ‘post’,
success: function(output) {
alert(output);
}
});

http://stackoverflow.com/a/13366307

PHP PDO: Text Encoding

$dbh = new PDO(“mysql:$connstr”, $user, $password);
$dbh->exec(“set names utf8”);

http://stackoverflow.com/a/4361485

Answer:Is there an equivalent for var_dump (PHP) in Javascript

function dump(obj) {
var out = ”;
for (var i in obj) {
out += i + “: ” + obj[i] + “\n”;
}

alert(out);

// or, if you wanted to avoid alerts…

var pre = document.createElement(‘pre’);
pre.innerHTML = out;
document.body.appendChild(pre)
}

http://stackoverflow.com/a/323809