Answer the question
In order to leave comments, you need to log in
How to process lines in textarea with ":" delimiter?
The essence of the problem
There is a form with textarea
<form action="" method="POST">
<textarea rows="10" cols="45" style="resize: none;height: 120px;width: 540px;" name="aks"><?php echo isset($_POST['aks']) ? htmlspecialchars($_POST['aks']) : ''; ?></textarea/>
<input type="submit"id="onetime" class="act1" value="Добавить">
</form>
if (isset($_POST['text'])){
$aks = explode("\n", $_POST['aks']);
foreach ($aks as $ak) {
mysql_query("INSERT INTO `vanek` SET aks='{$ak}'");
}
}
Answer the question
In order to leave comments, you need to log in
<?php
$users = <<<HTML
login1:pass1
login2:pass2
login3:pass3
HTML;
foreach (explode(PHP_EOL, $users) as $user) {
$user_data = explode(':', trim($user));
$login = $user_data[0];
$password = $user_data[1];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question