How would i split a string every 4 characters and then have every 4 characters put into a separate variable so i can do other stuff with each individual 4 characters?
Well, I don't really see you putting each of them in a different variable, because then you'll have like 10 variables:
$var1 = ...;
$var2 = ...;
$var3 = ...;
But you could use the str_split
function as following:
$variable = str_split($origionalvar, 4);
it will create an array, which you can access:
$variable[0]
to $variable[sizeof(variable)]
If you don't know about arrays, you really should read up on those. They are really great if you want to store a lot of similar information in an object and you don't want to create a new variable for it every time. Also you can loop over them very easily and do some other great stuff with them.
I assume you probably googled this question a bit too. You must have come across http://php.net/manual/en/function.str-split.php . Did you see this page, and if you did, did you have some trouble with it. If so perhaps we can help you reading the documentation properly.
Have a look at the str_split
function. The PHP manual will tell you all you need to know.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.