I have a file named sku.txt with SKU number in each line. File may contains from 1 SKU to 100 SKU's. I need to read this file and split in to variables for every 10 SKU numbers.
if file has 5 sku numbers, then skuvar1 = 5 sku numbers
if file has 19 numbers, then skuvar1 = 10 numbers and skuvar2 = 9 numbers
if file has 35 numbers, then skuvar1= 10, skuvar2= 20, skuvar3= 10 and skuvar4= 5
Can someone help me how to implement it.
Appreciate your help.
Thanks
Chris
Read and Split into Many variables
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Read and Split into Many variables
Probably better to use arrays:
Code: Select all
$skus = array_chunk(file('/path/to/sku.txt'), 5);mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Read and Split into Many variables
Thank you for the Tip. I will test it out.