Avatar of B O
B O

asked on 

How do I filter a json file and only process date_of_birth between ages 18 - 65 and unknown in Laravel

I am trying to figure out how to only process data with date of birth between 18-65 and uknown

$contactInfo = Storage::disk('local')->exists('challenge.json') ? json_decode(Storage::disk('local')->get('challenge.json'), true) : [];
        
            $chunks = array_chunk($contactInfo, 1000);


            foreach ($chunks[0] as $contactDetail ){

            ............

                $contact->date_of_birth = (strlen($contactDetail['date_of_birth']) == 10)
                ? Carbon::createFromFormat('d/m/Y', $contactDetail['date_of_birth'])
                : $contactDetail['date_of_birth'];
                
                
                // $contact->save();
                // $sensitive_data->save();
                // $contact->creditcards()->attach($sensitive_data->id);
            }



Open in new window




LaravelPHPJSON

Avatar of undefined
Last Comment
Chris Stanyon
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo