Get value from TXT file and import it into PHP value [closed]

I have an TXT file with approximately 10.000 lines to read, and each line contains a number, barcodes, EAN, UPC etc, I would like to get the value, each line by line and export it as an JSON/CSV or similar format which I can use later on.

How to fetch the $product_code = “GetBarcodeFromText” into the PHP code and execute it.

barcodes.txt contains for an example:

022517707319
015561756228
015561756211
015561822619
015561822626
015561825269
015561825276

Here is the code I have from GO-UPC.com. (I just need the results in any reading format that I can use in Excel.)


$api_key = 'API_KEY';
$product_code = '01020504050505';
$api_base_url = 'https://go-upc.com/api/v1/code/';
$url = $api_base_url . $product_code;

$ch = curl_init();

$data = get_product_data($url, $api_key, $ch);

$product_data = json_decode($data);

var_dump($product_data);

$product_name = $product_data->product->name;
$product_description = $product_data->product->description;
$product_image = $product_data->product->imageUrl;

?>

<p><?php echo $product_name; ?>,<?php echo $product_description; ?>,<?php echo $product_image; ?></p>

<?php

function get_product_data($url, $api_key, $ch) {
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Authorization: Bearer ' . $api_key
    ));
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}