Find Jobs
Hire Freelancers

Calculated Field from Array - Existing Code

$10-20 USD

Cancelado
Publicado há mais de 8 anos

$10-20 USD

Pago na entrega
I'm attempting to create a new mapping for a calculated field of two existing mappings. Something like: '(space/total_space)' => [ 'key' => 'Disk_Free_Percentage', ], Where 'space' is divided by 'total_space' to get a percentage. The code I am using this far is below and I am stuck on this last piece. Any help or pointers would be greatly appreciated. // Call API to get servers $rawData = $admin->servers(); // Data mapping $map = [ 'server_name' => [ 'key' => 'Node', ], 'space' => [ 'key' => 'Disk_Free_GB', ], 'total_space' => [ 'key' => 'Total_Disk_GB', ], 'ram' => [ 'key' => 'Free_RAM_GB', 'normalize' => function ($data) { return number_format($data / 1024, 2); }, ], 'total_ram' => [ 'key' => 'Total_RAM_GB', 'normalize' => function ($data) { return number_format($data / 1024, 2); }, ], 'numvps' => [ 'key' => 'VMs', ], 'version' => [ 'key' => 'Version', ], ]; // Remap data $data = []; foreach ($rawData['servs'] as $row) { $item = []; foreach ($map as $fieldName => $field) { // Validate key exists if (!isset($field['key'])) { throw new LogicException(sprintf('Field %s must supply a key', $fieldName)); } // Get data from API if (isset($row[$fieldName])) { $value = $row[$fieldName]; } else { // Use null if data not given by API $value = null; } // Run normalize where set if (isset($field['normalize']) && is_callable($field['normalize'])) { $value = call_user_func($field['normalize'], $value); } // Map to new data $item[$field['key']] = $value; } $data[] = $item; } // encode JSON $json = json_encode($data)
ID do Projeto: 9046824

Sobre o projeto

1 proposta
Projeto remoto
Ativo há 8 anos

Quer ganhar algum dinheiro?

Benefícios de ofertar no Freelancer

Defina seu orçamento e seu prazo
Seja pago pelo seu trabalho
Descreva sua proposta
É grátis para se inscrever e fazer ofertas em trabalhos
1 freelancers estão ofertando em média $20 USD for esse trabalho
Avatar do Usuário
I can start immediately once you assign it to me. I have seen your code. I am having experience in php.
$20 USD em 1 dia
5,0 (1 avaliação)
1,8
1,8

Sobre o cliente

Bandeira do(a) UNITED STATES
United States
0,0
0
Método de pagamento verificado
Membro desde dez. 3, 2015

Verificação do Cliente

Trabalhos semelhantes

Comprehensive Events & Staff Management App
€250-750 EUR
Services Exchange Marketplace wordpress Theme like simbi.com
€30-250 EUR
Custom e-commerce product page with unique QR CODE generation web application -- 2
$250-750 USD
Freight Brokerage TMS Development
$3000-5000 USD
Wordpress Web Development with Security
₹600-1500 INR
Bus Booking API Integration in Flutter -- 2
₹1500-12500 INR
WordPress to Shopify Conversion
₹1500-12500 INR
Engaging Redesign of Driving School Website
₹600-1500 INR
Woocommerce Theme Customization with 6 months client support from vendor
₹400-750 INR / hour
Multifaceted IPTV OTT Application Development
$250-750 USD
Online Scanner Development
$30-250 USD
supply chain software application designed to optimize inventory management based on AI, automate distribution to branches, and classify products based on demand.
₹75000-150000 INR
Dynamic Tech Recruitment Website Development
$30-250 USD
Website Repair: Malware and WordPress Update + SLL Install
$10-30 CAD
High-Interactivity UI Design for PHP Laravel
₹75000-150000 INR
NinjaTrader 8 ChartTrader UI Specialist
$10-30 USD
It will crawl and extract all itags from all images from Docker Hub, Quay.io, AWS ECR Public Gallery, Snapcraft, Flatpak, AppImages, Bundles, BitTorrent, EDonkey2000, SoulSeek and DC++, and it will build and publish deb packages (as APT repository).
€8-30 EUR
Full-Stack Developer for Drupal Component Library (Description Updated)
$10-50 USD
Pine Script Extraction from Tradingview
£20-250 GBP
Looking for a business analyst to prepare flowchart diagrams for an ERP system -- 2
$50-70 USD
Obrigado! Te enviamos um link por e-mail para que você possa reivindicar seu crédito gratuito.
Algo deu errado ao enviar seu e-mail. Por favor, tente novamente.
Usuários Registrados Total de Trabalhos Publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Carregando pré-visualização
Permissão concedida para Geolocalização.
Sua sessão expirou e você foi desconectado. Por favor, faça login novamente.