This might be just a simple question, but I’m not very familiar in terms of PHP.
I have here a list of words separated by a < br / > tag, example:
<div id="list">
gmail.com<br />
yahoo.com<br />
yahoo.co.jp
</div>
And, I want to convert it to a list of values in an array looking like this
$acceptedDomains = array('gmail.com', 'yahoo.com', 'yahoo.co.jp');
How can I achieve this output?
I need this actually for domain email checking and here’s how the function works:
$acceptedDomains = array('gmail.com', 'yahoo.com', 'yahoo.co.jp');
$email = $current_user->user_email;
if(in_array(substr($email, strrpos($email, '@') + 1), $acceptedDomains)) {
//if user is a member, show form.
echo $email . " is valid" . "<div>" . CFS()->get('mo_email_list') . "</div>";
}
I want to replace the value of $acceptedDomains to what was listed under the id=”list”
Try below code:
Output:
Array ( [0] => gmail.com [1] => yahoo.com [2] => yahoo.co.jp )
Try this
Above Code will return the output
as per you want ):
Try this:
You can try below code:
OUTPUT of Above Code :
Simply do:
Or if
<div id="list"></div>
is also a part ofCFS()->get('mo_email_list')
output try:Please try below code.