Hi,
I have a textarea where the user can create a feature list with a title for each block of features. The idea is to store the [title] and the features in two different MySQL tables.
[Outdoor]
BBQ
Tennis court
Swimming pool[Internal Equipment]
DVD Player
Plasma screen
Here is what I've done so far; it works but it's not neat:
<form name="form" method="get" action="">
<p>
<textarea name="content" cols="35" rows="12" id="content"><?
if (isset($_GET['content'])) echo $_GET['content']; ?></textarea>
</p>
<p>
<input name="parse" type="submit" id="parse" value="Parse">
</p>
</form>
<?php
if(isset($_GET['parse']))
{
$content = $_GET['content'];
$content = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $content);
$content = trim($content);
$content1 = preg_replace('/\r\n|\r/', "\n", $content );
$data = explode("\n", $content1);
$p=0;
foreach ($data as $title) {
if (substr_count($title, '[')||substr_count($title, ']')){
$p++;
$arr[$p]=$title;
}else {
$g[$p][]=$title;
}
}
print_r($arr);
echo '<br />';
print_r($g);
}
?>
Thanks for your ideas.