Jump to content

Epimetheus1980

New Members
  • Posts

    7
  • Joined

  • Last visited

Epimetheus1980's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks. Yes, I think I need to do that. I'm just wondering why regex does not work.
  2. Thank you! It seems to work, although some special characters are displayed wrongly. However, I would have preferred to extract the respective div class by regex, because I first would like to display the actual content of the article, then the bibliography and finally the footnote, which just appears occasionally. That was the reason why I wanted to split the content field.
  3. I draw contents from a database. Some of the texts contain a footnote, which is formatted using a div class. Following the HTML of this: <div class=""footnotes""> <br> <hr align=""left"" noshade=""noshade"" size=""1"" width=""150"" /> <blockquote> <a href=""#f1"" name=""fn1""> <span class=""superscript""> * </span> </a>Some footnotetext</blockquote></div> Since my bibliography uses data from the database as well, the footnote now appears before the references, but I would like it at the very bottom of the page. I was thinking of using preg_replace in order to separate the textfield into two variables, one for the text itself, the other one for the footnote (it is always just one) and integrate after the bibliography is compiled. Unfortunately, it seems that the preg_replace does not work. It always displays the whole content of the textfield. Here's the PHP: $text = preg_replace('/(.*)(\div class=\"footnotes\"\>.*?\<\/div\>)/s', '$1', $result['text']);$footnote = preg_replace('/(.*)(\div class=\"footnotes\"\>.+?\<\/div\>)/s', '$2', $result['text']); echo '<div align="justify"><span style="font-family:Georgia;font-size:16px;">' . $text; ***BIBLIOGRAPHY*** ... echo $footnote; Maybe someone has an idea how to deal with that. I tried it on phpliveregex. There search string works fine. Many thanks for any help.
  4. Thank you. That's all already implemented. I just simplified it by using a string similar to the field in Table 1. My problem was that I didn't understand how to assign the values (years) to the respective keys (authors).
  5. Thank you. Although this makes sense to me, I am not sure about filling the array. Here is my current code. I do not know how to implement the associative array with the year-values. $arr = array(); foreach(explode(';', $string) as $pair) { $author = preg_replace("/([A-Za-z]*)([0-9]*[a-z]?)/", "$1", $pair); $year = preg_replace("/([A-Za-z]*)([0-9]*[a-z]?)/", "$2", $pair); $arr[$author] = null; } foreach($arr as $key=>$val) { echo "<p>" . $key . "</p>"; }
  6. I am very grateful for any input. I have a field in a database that contains references (pattern: authorYYYY), such as the following string: "authorA1989; authorB1978a; authorB1984; authorC1999; authorC2000a; authorC2000b; authorC2002; authorD2009" What I want is an output as the following in order to create a proper bibliography (therefore accessing another table and picking out the respective reference details): authorA 1989 authorB 1978a 1984 authorC 1999 2000a 2000b 2002 authorD 2009 I somewhat fail to group the values (years) per author. I know that keys are unique, but is there a way to work around this? Many thanks for any help!
  7. I'm trying to work with prepared statements, but unfortunately I do not get any result back. I also tried while($stmt->fetch()) { ... }, with the same effect. Does anyone have a suggestion? Thanks in advance. <?php MAKING CONNECTION if ($stmt = $mysqli->prepare("SELECT year FROM SOMETABLE WHERE id = ? LIMIT 1")) { $id = $_GET['id']; $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($year); $stmt->fetch(); echo $year; $stmt->close(); } $mysqli->close(); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.