ダミー情報を生成する定番.

2024.03.29

Logging

ダミー情報を生成する定番を生成する定番のコードを記載します.
Composerを使用し’faker’をインストールします.

composer require fakerphp/faker

使用方法例のコードとしてcsv出力するコードを記載(下記).

<?php
require 'vendor/autoload.php';
use Faker\Factory;

class CsvGenerate{
    /**
     * ダミー情報を生成する
     * @param int $max
     * @return string
     */
    public function csvMake(int $max=0):string
    {
        $faker = Factory::create('ja_JP');
        $hasData = [];
        for($i=0;$i<$max;$i++){
            $datas = [];
            $datas[0] = $faker->name();
            $datas[1] = $faker->email();
            $datas[2] = $faker->phoneNumber();
            $datas[3] = $faker->address();
            $hasData[$i] = implode(',',$datas);
        }

        return implode(PHP_EOL,$hasData);
    }
}

print((new CsvGenerate)->csvMake(1000));
//file_put_contents('data.csv',(new CsvGenerate)->csvMake(1000));

実際使用する場合は、file_put_contents行のコメントを解除してください.
同階層にdata.csvファイルが作成されます.
尚、コマンドよりファイルを実行することを想定しています.

※参考にしたサイト
https://fakerphp.github.io/
https://qiita.com/kurosuke1117/items/c672405ac24b03af2a90

明日へ続く.

著者名  @taoka_toshiaki

※この記事は著者が40代前半に書いたものです.

Profile
高知県在住の@taoka_toshiakiです、記事を読んで頂きありがとうございます.
数十年前から息を吸うように日々記事を書いてます.たまに休んだりする日もありますがほぼ毎日投稿を心掛けています😅.
SNSも使っています、フォロー、いいね、シェア宜しくお願い致します🙇.
SNS::@taoka_toshiaki

OFUSEで応援を送る

タグ

$datas, $hasData, Address, Composer, create, csvMake, faker’, gt, implode, items, lt, name, phoneNumber, php require, print, qiita.com, string, vendor,

I have a story about requesting a PS5 invitation.

2023.06.21

Logging

Good morning. After spending two days staring at Amazon and wrestling with the decision, I impulsively clicked “Buy” on the PS5 invitation request. However, I still haven’t received the purchase invitation email. It seems that most people receive the invitation email within about two weeks. Also, I learned that this invitation request remains valid for 12 months from the moment of purchase, so I’ll patiently wait.

In addition, the PSVR converter arrived the other day, and it’s sitting beside my PS4 as I wonder when I’ll be able to use it. I can’t help but wonder if it’s a system where Amazon’s Black Card holders, for example, get priority access to purchase items. It doesn’t seem to be just a first-come, first-served basis.

There must be people who planned to purchase a PS5 at least in time for the release of FF16. If it were Akihabara or somewhere similar, it would probably be relatively easy to buy a PS5, but since I live in a rural area, buying online is the norm.

It would be quite a shock if it turned out that they actually had them in stock at local stores like Yamada Denki… but I highly doubt it. Still, I’ll go take a look, just in case.

著者名  @taoka_toshiaki

※この記事は著者が40代前半に書いたものです.

Profile
高知県在住の@taoka_toshiakiです、記事を読んで頂きありがとうございます.
数十年前から息を吸うように日々記事を書いてます.たまに休んだりする日もありますがほぼ毎日投稿を心掛けています😅.
SNSも使っています、フォロー、いいね、シェア宜しくお願い致します🙇.
SNS::@taoka_toshiaki

OFUSEで応援を送る

タグ

also, Buy, decision, first-served basis, haven't received the purchase invitation, highly doubt, However, I'll, invitation email, It doesn't, It seems, it would, items, like Yamada Denki, patiently wait, similar, so I'll, Still, weeks, when,