$values = array_map(function($v){
return str_pad($v, 4, '0', STR_PAD_LEFT);
}, range(1, 9999));
class Form1
{
...
public void buttonClick(object sernder, EventArgs arg)
{
...
form2.UpdateFields(name, lastName);
form2.Show();
}
...
}
class Form2
{
...
public void UpdateFields(string name, string lastname)
{
nameTextBox.Text = name;
lastNameTextBox.Text = lastname;
}
...
}
{
"filmName":{
"2014-08-20":
["10:20","16:15","18:25"],
"2014-08-15":
["10:20","16:15","18:25"]
}
}
Array ( [Неудержимые 3] => array( 2014-08-19 => array(10:20, 16:15, 18:25, 20:40, 23:00),
2014-08-19 => array(10:20, 16:15, 18:25, 20:40, 23:00) ) )
$myArray = array(...);
$remakeArray = function($myArray){
$convertArray = array();
for($key in $myArray){
if($convertArray[$myArray[$key]["films_title_rus"]]){
$convertArray[$myArray[$key]["films_title_rus"]] = array();
}
$convertArray[$myArray[$key]["films_title_rus"]][$myArray[$key]["schedule_date"]] = $myArray[$key]["schedule_time"];
}
return $convertArray;
};
$myArray = $remakeArray($myArray);
$arr = array(array('id' => 1, 'year' => 2013, 'name' => "Александр"),
array('id' =>2, 'year' => 2013, 'name' => "Сергей"),
array('id' => 3, 'year' => 2012, 'name' => "Никита"),
array('id' => 4, 'year' => 2012, 'name' => "Володя"));
function by_year($arr) {
$result = array();
foreach ($arr as $l) {
$result[$l['year']][] = $l['name'];
}
return $result;
}
print_r(by_year($arr));
Array
(
[2013] => Array
(
[0] => Александр
[1] => Сергей
)
[2012] => Array
(
[0] => Никита
[1] => Володя
)
)
$arr = array(array('id' => 1, 'year' => 2013, 'name' => "Александр"),
array('id' =>2, 'year' => 2013, 'name' => "Сергей"),
array('id' => 3, 'year' => 2012, 'name' => "Никита"),
array('id' => 4, 'year' => 2012, 'name' => "Володя"));
function group_by_year($arr) {
$newarr = array();
foreach($arr as $val) {
if (isset($newarr[$val['year']])) {
$index = 0;
while (1) {
if (!isset($newarr[$val['year']]['name'.$index]))
$newarr[$val['year']]['name'.$index] = $val['name'];
break;
$index++;
}
}
else {
$newarr[$val['year']] = $val;
unset($newarr[$val['year']]['year']);
}
}
return $newarr;
}
print_r(group_by_year($arr));