Forum Moderators: coopster
Below is some pseudocode, which I hope further illustrates what I mean.
$count = 60;
for ($i = 1; $i <= $count; ++$i) {
$reg =
}
This has got me a bit stumped.
After I have managed to make the array.
I would then like to explode this array out into variables - each one assigned a value of $reg
I realise that this may be quite a basic Q. And i really do apoligise. I have read up on arrays and am having trouble applying it to this
situation. Thanks very much.
P.S A further complication that I would like to accommodate is that $reg may be assigned a number of values in a single "for loop". I would like to
collect all these values.
The pseudocode for this:
$count = 60;
for ($i = 1; $i <= $count; ++$i) {
$reg =
$reg =
}
If this post is difficult to follow - dont hesitate to post back and I will try my best to expand. It is just I didnt want to make this post too long and
put people off.
P.S It may be helpful to know what is actually in the "for loop":
for() {
$regex = "/(([A-Za-z0-9]+_+)?[A-Za-z0-9]+\-+)?[A-Za-z0-9]+\.+)?[A-Z
a-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)?\w+\.))*\w{1,63}\.[a-z
A-Z]{2,6}/";
preg_match_all($regex, $data, $reg))
}
$new_reg[] = $reg;
Is it called:
$new_reg[]
or
$reg[]
I am not quite sure. How I want to apply the name of the array:
1) I want to explode the array into variables.
$emailsss = explode(",", $new_reg[]);
print $emailsss[0];
print $emailsss[1];
2) On a different tangent.
The array is actually an array of email addresses.
I want to send an email to each email address in the array. Am I going somewhere with this code?
foreach($reg as $email){
$mailaddress = $email;
$mailsubject = "My Subject";
$mailbody = "Hello, world!";
mail($mailaddress, $mailsubject, $mailbody);
}
Many thanks for your patience
The array would be named $new_reg()
$new_reg = array();
1) I want to explode the array into variables.
$emailsss = explode(",", $new_reg[]);
Try this:
$emailsss = explode(",", $new_reg);
foreach($reg as $email){
for ($i = 1; $i <= $count; ++$i) {
$new_reg[] = $reg;
}
This would just add the value of $reg, however many times the loop executes. So if $count has the value of 5, you would have the value of $reg 5 times.
How are the values of $reg being assigned?