Hello guys, i'm new here. I would like to convert my .txt file which have the following content into an array of int which every elemnt in the array should only have 4 character inside.


two[1]= 0x03;
two[2]= 0x00;
two[3]= 0x03;
two[4]= 0xf5;

This is the content of my file:


Recommended Answers

use str_split() method.

read file and let the variable in which file content is there is $str.

$arr2 = str_split($str, 4);

For more info http://php.net/manual/en/function.str-split.php

Jump to Post

All 4 Replies

can anyone move this thread to C programming? i posted wrongly.

admin pls delete this thread. thank you.

Normally in every programming language we have a split function and different functions which can be used to fInd or search sUb string or charachters in a STRING but approach should also be part of concern that it is not supposed to hit the performance as it may also require a loop that could be consumption of space and time . Since you are a beginner I will sugest you to learn algorithms which can help you to have good programming approch

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.