当前位置: 首页>>代码示例>>PHP>>正文


PHP transform函数代码示例

本文整理汇总了PHP中transform函数的典型用法代码示例。如果您正苦于以下问题:PHP transform函数的具体用法?PHP transform怎么用?PHP transform使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了transform函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFilteredEntries

 public function getFilteredEntries($lastNames)
 {
     $entries = Entry::with('restorationType')->with('folders')->whereIn('last_name', $lastNames)->get();
     //Transform
     $resource = createCollection($entries, new EntryTransformer());
     return transform($resource)['data'];
 }
开发者ID:JennySwift,项目名称:dental,代码行数:7,代码来源:EntriesRepository.php

示例2: __construct

 /**
  * Change to a static constructor or not, up to you
  * @param null $budgets
  */
 public function __construct($budgets = NULL)
 {
     $this->type = Budget::TYPE_FIXED;
     $this->budgets = $budgets ?: Budget::forCurrentUser()->whereType(Budget::TYPE_FIXED)->get();
     $this->amount = $this->calculate('amount');
     $this->remaining = $this->calculate('remaining');
     $this->cumulative = $this->calculate('cumulative');
     $this->spentBeforeStartingDate = $this->calculate('spentBeforeStartingDate');
     $this->spentOnOrAfterStartingDate = $this->calculate('spentOnOrAfterStartingDate');
     $this->receivedOnOrAfterStartingDate = $this->calculate('receivedOnOrAfterStartingDate');
     //Transform budgets
     $resource = createCollection($this->budgets, new BudgetTransformer());
     $this->budgets = transform($resource);
 }
开发者ID:JennySwift,项目名称:budget,代码行数:18,代码来源:FixedBudgetTotal.php

示例3: gb2312_to_latin

function gb2312_to_latin($string)
{
    $output = "";
    for ($i = 0; $i < strlen($string); $i++) {
        $letter = ord(substr($string, $i, 1));
        if ($letter > 160) {
            $tmp = ord(substr($string, ++$i, 1));
            $letter = $letter * 256 + $tmp - 65536;
            // echo "%$letter%";
        }
        $output .= transform($letter);
    }
    return $output;
}
开发者ID:Peter2121,项目名称:leonardoxc,代码行数:14,代码来源:convert_gb2312.php

示例4: reverse_recurse

function reverse_recurse($string, $step = 0)
{
    global $reverse, $min;
    if ($string == 'e') {
        if ($step < $min) {
            $min = $step;
            print "min: {$min}\n";
        }
    } else {
        foreach (transform($reverse, $string) as $reversed) {
            reverse_recurse($reversed, $step + 1);
        }
    }
}
开发者ID:MaMa,项目名称:adventofcode,代码行数:14,代码来源:day19.php

示例5: store

 /**
  * Insert an exercise entry.
  * It can be an exercise set.
  * @param Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $exercise = Exercise::find($request->get('exercise_id'));
     if ($request->get('exerciseSet')) {
         // We are inserting an exercise set
         $quantity = $exercise->default_quantity;
         $unit = Unit::find($exercise->default_unit_id);
     } else {
         $quantity = $request->get('quantity');
         $unit = Unit::find($request->get('unit_id'));
     }
     $entry = new Entry(['date' => $request->get('date'), 'quantity' => $quantity]);
     $entry->user()->associate(Auth::user());
     $entry->exercise()->associate($exercise);
     $entry->unit()->associate($unit);
     $entry->save();
     //Return the entries for the day
     $entries = transform(createCollection($this->exerciseEntriesRepository->getEntriesForTheDay($request->get('date')), new ExerciseEntryTransformer()))['data'];
     return response($entries, Response::HTTP_CREATED);
 }
开发者ID:JennySwift,项目名称:health-tracker,代码行数:26,代码来源:ExerciseEntriesController.php

示例6: responseCreatedWithTransformer

 /**
  * Return response created code with transformed resource
  * @param $resource
  * @return mixed
  */
 public function responseCreatedWithTransformer($resource, $transformer)
 {
     //Transform
     $resource = createItem($resource, $transformer);
     return response(transform($resource), Response::HTTP_CREATED);
     /**
      * @VP:
      * Why do all this stuff when I could just do this:
      * return response(transform($resource), Response::HTTP_CREATED);
      */
     //        $manager = new Manager();
     //        $manager->setSerializer(new DataArraySerializer);
     //
     //        $manager->parseIncludes(request()->get('includes', []));
     //
     //        return response()->json(
     //            $manager->createData($resource)->toArray(),
     //            Response::HTTP_CREATED
     //        );
 }
开发者ID:JennySwift,项目名称:budget,代码行数:25,代码来源:Controller.php

示例7: main

/**
 * Main functions. Just decides what mode we are in and calls the
 * appropriate methods.
 */
function main()
{
    global $info, $config;
    $args = Console_Getopt::readPHPArgv();
    if (count($args) < 2) {
        print_usage_info();
    }
    if (substr($args[1], 0, 1) == "-" || substr($args[1], 0, 1) == "/") {
        print "invalid parameter " . $args[2] . "\n";
        print_usage_info();
    }
    if (substr($args[1], -4) == ".php") {
        // mode 2: create zombie app
        if (!file_exists($args[1])) {
            die("config file " . $args[1] . " does not exist\n");
        }
        read_config_file($args[1]);
        $outdir = ZOMBIE_BASE . '/../' . Horde_String::lower($config['app']);
        if (is_dir($outdir) && $args[2] != "-f") {
            print "Directory {$outdir} already exists.\nUse -f flag to force overwrite\n";
            exit;
        }
        $n = $config['app'];
        print "Creating Horde Application {$n} in directory " . Horde_String::lower($n) . "\n";
        transform($outdir);
        print "\nHorde Application '{$n}' successfully written. Where to go from here:\n" . "1) Paste content of {$n}/registry.stub to horde/config/registry.php.\n" . "   After that, the {$n} should be working!\n" . "2) Replace {$n}.gif with proper application icon\n" . "3) Ensure conf.php is not world-readable as it may contain password data.\n" . "4) Start playing around and enhancing your new horde application. Enjoy!\n";
    } else {
        // mode 1: create config file
        parse_options($args);
        print "creating config file for table " . $config['table'] . "\n";
        create_table_info();
        enhance_info();
        print "writing config file to " . $config['file'] . "\n";
        dump_config_file();
    }
}
开发者ID:Gomez,项目名称:horde,代码行数:40,代码来源:rampage.php

示例8: runit

function runit($title, $tx, $ty)
{
    $text = explode("\n", read_from_url($title));
    $ret = array();
    foreach ($text as $t) {
        if (trim(strtolower(substr($t, 0, 6))) == ";data:") {
            $r = array();
            $t = explode(";", substr($t, 6));
            foreach ($t as $s) {
                $set = array();
                $s = explode(" ", trim($s));
                foreach ($s as $part) {
                    $part = explode(",", $part);
                    $set[] = transform($part, $tx, $ty);
                }
                $r[] = implode(" ", $set);
            }
            $ret[] = ";data:" . implode(";", $r);
        } else {
            $ret[] = $t;
        }
    }
    return $ret;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:24,代码来源:fix_coordinates.php

示例9: getRecipeInfo

 /**
  * Get recipe contents and steps.
  * Contents should include the foods that belong to the recipe,
  * along with the description, quantity, and unit
  * for the food when used in the recipe (from food_recipe table),
  * and with the tags for the recipe.
  * Redoing after refactor. Still need description, quantity, unit.
  * @param $recipe
  * @return array
  */
 public function getRecipeInfo($recipe)
 {
     $recipe = transform(createItem($recipe, new RecipeWithIngredientsTransformer()))['data'];
     //For some reason the units for each food aren't being added to the food
     //from my IngredientTransformer, so add them here
     foreach ($recipe['ingredients']['data'] as $index => $ingredient) {
         $units = Food::find($ingredient['food']['data']['id'])->units;
         $units = transform(createCollection($units, new UnitTransformer()));
         $recipe['ingredients']['data'][$index]['food']['data']['units'] = $units;
     }
     return $recipe;
 }
开发者ID:JennySwift,项目名称:health-tracker,代码行数:22,代码来源:RecipesRepository.php

示例10: transform

<?php

function transform($num)
{
    if ($num % 3 == 0 and $num % 5 == 0) {
        $num = "MaxGood";
    } else {
        if ($num % 3 == 0) {
            $num = "Max";
        } else {
            if ($num % 5 == 0) {
                $num = "Good";
            }
        }
    }
    return $num;
}
for ($i = 1; $i <= 100; $i++) {
    echo transform($i) . ', ';
}
开发者ID:parigematria,项目名称:satu,代码行数:20,代码来源:tiga.php

示例11: getExercises

 /**
  * Get all exercises for the current user,
  * along with their tags, default unit name
  * and the name of the series each exercise belongs to.
  * Order first by series name, then by step number.
  * @return mixed
  */
 public function getExercises()
 {
     $exercises = Exercise::forCurrentUser('exercises')->with('defaultUnit')->orderBy('step_number')->with('series')->with('tags')->get();
     return transform(createCollection($exercises, new ExerciseTransformer()))['data'];
 }
开发者ID:JennySwift,项目名称:health-tracker,代码行数:12,代码来源:ExercisesRepository.php

示例12: fopen

            return 4;
        case 'five':
            return 5;
        case 'six':
            return 6;
        case 'seven':
            return 7;
        case 'eight':
            return 8;
        case 'nine':
            return 9;
        case 'zero':
            return 0;
    }
}
$fh = fopen($argv[1], "r");
while (!feof($fh)) {
    $numbers = fgets($fh);
    $numbers = trim($numbers);
    $numbers_array = explode(';', $numbers);
    if (count($numbers_array) > 20) {
        echo "Only 20 numbers are allowed per line";
    } else {
        foreach ($numbers_array as $number) {
            $number = strtolower($number);
            $digit = transform($number);
            echo $digit;
        }
    }
    echo "\n";
}
开发者ID:kcabading,项目名称:CodeEvalChallenges,代码行数:31,代码来源:wordtodigit.php

示例13: ejecutaConsulta

}
//comprobamos la gente a la que se le ha pasado la fecha de inscripcion
$resultado = ejecutaConsulta("select fechaadmision,correo from usuario where estado=1");
$filas = pg_numrows($resultado);
if ($filas != 0) {
    $i = 0;
    for ($cont = 0; $cont < $filas; $cont++) {
        $correo = pg_result($resultado, $cont, 'correo');
        $fechaadmision = pg_result($resultado, $cont, 'fechaadmision');
        $date = date("Y-m-d G:i:s");
        $admitido = transform($fechaadmision);
        $hoy = transform($date);
        $dias = ($hoy - $admitido) / 86400;
        if ($dias > 3) {
            $elementosBorrar[$i] = $correo;
            $i = $i + 1;
        }
    }
    $numelem = count($elementosBorrar);
    for ($j = 0; $j < $numelem; $j++) {
        $correo = $elementosBorrar[$j];
        $resultado = ejecutaConsulta("Delete from usuario where correo='{$correo}';");
    }
}
$hoy = date("Y-m-d G:i:s");
$ayer = transform(date("Y-m-d G:i:s"));
$ayer = $ayer - 86400;
$ayer = date("Y-m-d G:i:s", $ayer);
$resultado = ejecutaConsulta("Select count(*) from usuario where fechabaja BETWEEN '{$ayer}' and '{$hoy}' and estado=4;");
$contador = pg_result($resultado, 0, 0);
mandarCorreoContadorBaja($contador, $ayer, $hoy);
开发者ID:snake77se,项目名称:jornadasgvsig,代码行数:31,代码来源:aplicacionCron.php

示例14: __

    exit;
}
$status = '';
if (isset($_FILES['templateFile']) && $_FILES['templateFile']['error'] == 0 && ($_FILES['templateFile']['type'] = 'text/xml')) {
    $result = $template->ImportTemplate($_FILES['templateFile']['tmp_name']);
    $status = $result["status"] == "" ? __("Template File Imported") : $result["status"] . '<a id="import_err" style="margin-left: 1em;" title="' . __("View errors") . '" href="#"><img src="images/info.png"></a>';
}
if (isset($_REQUEST['TemplateID']) && $_REQUEST['TemplateID'] > 0) {
    //get template
    $template->TemplateID = $_REQUEST['TemplateID'];
    $template->GetTemplateByID();
    $deviceList = Device::GetDevicesByTemplate($template->TemplateID);
}
if (isset($_POST['action'])) {
    $template->ManufacturerID = $_POST['ManufacturerID'];
    $template->Model = transform($_POST['Model']);
    $template->Height = $_POST['Height'];
    $template->Weight = $_POST['Weight'];
    $template->Wattage = isset($_POST['Wattage']) ? $_POST['Wattage'] : 0;
    $template->DeviceType = $_POST['DeviceType'];
    $template->PSCount = $_POST['PSCount'];
    $template->NumPorts = $_POST['NumPorts'];
    $template->ShareToRepo = isset($_POST['ShareToRepo']) ? 1 : 0;
    $template->KeepLocal = isset($_POST['KeepLocal']) ? 1 : 0;
    $template->Notes = trim($_POST['Notes']);
    $template->Notes = $template->Notes == "<br>" ? "" : $template->Notes;
    $template->FrontPictureFile = $_POST['FrontPictureFile'];
    $template->RearPictureFile = $_POST['RearPictureFile'];
    $template->ChassisSlots = $template->DeviceType == "Chassis" ? $_POST['ChassisSlots'] : 0;
    $template->RearChassisSlots = $template->DeviceType == "Chassis" ? $_POST['RearChassisSlots'] : 0;
    $template->SNMPVersion = $_POST['SNMPVersion'];
开发者ID:actatux,项目名称:openDCIM,代码行数:31,代码来源:device_templates.php

示例15: getFoods

 /**
  * Get all foods, along with their default unit, default calories,
  * and all their units.
  * Also, add the calories for each food's units. Todo?
  * @return mixed
  */
 public function getFoods()
 {
     $foods = Food::forCurrentUser()->with('defaultUnit')->orderBy('foods.name', 'asc')->get();
     $foods = transform(createCollection($foods, new FoodTransformer()));
     return $foods['data'];
 }
开发者ID:JennySwift,项目名称:health-tracker,代码行数:12,代码来源:FoodsRepository.php


注:本文中的transform函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。