Jump to content

bluebyyou

Members
  • Posts

    234
  • Joined

  • Last visited

    Never

About bluebyyou

  • Birthday 03/04/1984

Contact Methods

  • AIM
    lncerevo8
  • Website URL
    http://www.michaelpisula.com

Profile Information

  • Gender
    Male
  • Location
    Illinois

bluebyyou's Achievements

Member

Member (2/5)

0

Reputation

  1. <?php $str = "Some {sample|example|variable} text. More {text|things|stuff} text."; $pattern ="/\{.*\}/is"; preg_match_all($pattern, $str, $matches); foreach ($matches as $val) { print_r($val); } ?> It outputs: Array ( [0] => {sample|example|variable} text. More {text|things|stuff} ) ------------- What I want the output to be is each string between the {}'s to be parsed out individually, I just am having a hell of a time writing the proper regular expression. Can someone point me in the right direction?
  2. thorpe, I did not need that, it was my attempt at a solution that did not work. Dragen, that did the trick, thanks.
  3. I have my rewrite rules working how I want them, however my links that I am dynamically creating are not for example my link is: www.website.com/article/1/1. when i click a link on that page it becomes: www.website.com/article/1/1/article/1/1 and if i click it a third time it becomes: www.website.com/article/1/1/article/1/1/article/1/1 and so on... the current path repeats it self over everytime I click it Here are my rewrite rules... RewriteEngine On RewriteRule ^article/([0-9]+)/([0-9]+)$ article.php?categoryID=$1&articleID=$2 [NC] RewriteRule ^article/([0-9]+)$ article.php?categoryID=$1 [NC,L] here is a sample of me creating a link echo "<h3><a href='../article/".$display_category['category_id']."'>".$display_category['category_title']."</a></h3>\n"; //Show Category Title also i tried using ../../ etc in front of the links, but then the more you click the the link the farther back in the directory it goes. so that didnt work either.
  4. I finally figured it out, all I had to do was set the LIMIT on the preg_replace function to replace one image tag at a time. Here is the code if anyone is interested. What it does is parse text, like a content management system might, and also replaces a number tags from an array of image names. <?php function code_format ($str,$images) { //remove html tags $str = htmlentities($str); $tag_identifiers = array( '/\[b\](.*?)\[\/b\]/is' => '<strong>$1</strong>', '/\[i\](.*?)\[\/i\]/is' => '<em>$1</em>', '/\[u\](.*?)\[\/u\]/is' => '<u>$1</u>', //'/\[url\=(.*?)\](.*?)\[\/url\]/is' => <a href="$1">$2</a>', //'/\[url\](.*?)\[\/url\]/is' => '<a href="$1">$1</a>, //'/\[align\=(left|center|right)\](.*?)\[\/align\]/is' => '<div style="text-align: $1;">$2</div>', //'/\[img\](.*?)\[\/img\]/is' => '<img src="$1" />', //'/\[mail\=(.*?)\](.*?)\[\/mail\]/is' => '<a href="mailto:$1">$2</a>', //'/\[mail\](.*?)\[\/mail\]/is' => '<a href="mailto:$1">$1</a>', //'/\[font\=(.*?)\](.*?)\[\/font\]/is' => '<span style="font-family: $1;">$2</span>', //'/\[size\=(.*?)\](.*?)\[\/size\]/is' => '<span style="font-size: $1;">$2</span>', //'/\[color\=(.*?)\](.*?)\[\/color\]/is' => '<span style="color: $1;">$2</span>', //'/\[img\]/is' => '%s', '/\[ret\]/is' => '<br /><br />', ); // Do simple tag replacements $str = preg_replace (array_keys($tag_identifiers), array_values($tag_identifiers), $str); // Do image replacements foreach ($images as $key => $value) { $str = preg_replace ('/\[img\]/is', "<img src='".$value."' />" , $str, 1); } echo $str; } $images = array('1.jpg','2.jpg','3.jpg','4.jpg','5.jpg'); $text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin sit amet risus enim. Nunc urna libero, porta eu tristique vel, porta vel est. Phasellus imperdiet commodo mauris sit amet eleifend. Fuscemi sem, suscipit sed rhoncus a, egestas sed nisl. Phasellus cursus eleifend congue. Vestibulum sit amet ante blandit massa aliquam porta. [img] Nulla lacinia purus non justo iaculis ultrices. Nunc sollicitudin odio sed ligula hendrerit vel euismod turpis porttitor. [b]Pellentesque suscipit[/b], tellus quis gravida blandit, quam tellus posuere ante, ut egestas odio erat nec augue. Praesent hendrerit mi sed metus suscipit hendrerit. Sed non ullamcorper ante. Phasellus nibh mauris, placerat at sodales non, tempus id dolor. In ullamcorper urna purus.[ret]\n\n". "Duis suscipit leo eget eros accumsan in auctor dui placerat. Quisque id dui quam, porttitor varius nisi. Maecenas vestibulum sagittis neque vitae blandit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed tortor mi, sodales vitae fringilla commodo, pellentesque sit amet nisl. Proin aliquam metus in velit blandit at molestie sapien dapibus. Ut sollicitudin lectus id massa suscipit lacinia. Sed ante felis, ultrices et iaculis nec, tristique at sem. Donec a augue et orci convallis semper. [img] Vestibulum mi neque, accumsan vel suscipit quis, cursus quis lacus. Vivamus vulputate cursus odio, eget cursus urna consequat vitae. Cras laoreet iaculis quam commodo malesuada. [i]Praesent scelerisque laoreet nisl, eu tempor diam gravida et. Ut dictum sodales nisi[/i]. Morbi viverra ornare porttitor. Ut pretium urna sed arcu venenatis et ultricies elit aliquam. Ut ut sollicitudin neque. Praesent orci magna, convallis et cursus vitae, ornare eget erat. Integer id est nec odio pulvinar tincidunt.[ret]\n\n". "Praesent id sapien libero, sit amet tincidunt lorem. Quisque volutpat nisi a tortor fringilla et scelerisque enim dignissim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse non mollis nunc. Duis vel molestie magna. Praesent nisi elit, posuere vel convallis id, mollis vitae dui. Vivamus aliquet semper dapibus. In ultricies molestie convallis. Vivamus hendrerit tellus venenatis lorem vulputate at interdum sapien dictum. Sed urna neque, facilisis et posuere nec, sodales rutrum nisi. [img] Suspendisse potenti. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; [u]In id mi eros, a iaculis arcu[/u]. Maecenas consequat consequat congue. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam blandit, nunc vitae sodales rutrum, nisi neque viverra massa, vulputate venenatis elit lacus vitae arcu. Curabitur at ante ipsum. Quisque sodales mauris a arcu sodales nec fringilla lacus interdum. In in lobortis dui. In malesuada, diam ac auctor interdum, massa nibh scelerisque augue, et tincidunt lectus purus eget lectus.[ret]\n\n". "Aliquam adipiscing tincidunt posuere. Suspendisse non purus nisl, at dapibus sapien. Maecenas posuere urna ac nibh scelerisque malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Phasellus sed nibh tortor, ac porta orci. Mauris ac turpis vitae libero vehicula pellentesque. Quisque vel urna sed magna pellentesque varius a et ligula. Proin ultricies magna at nibh auctor imperdiet. Nullam sed erat mauris, id laoreet augue. Pellentesque enim est, accumsan varius mattis ac, convallis sit amet velit. Cras nulla risus, laoreet ac consectetur ut, tristique ac lorem. Curabitur scelerisque elit eget nunc eleifend eu fringilla nibh porttitor. [img] Sed ullamcorper vestibulum orci, vel interdum turpis semper non. Quisque id malesuada velit. Praesent a est nulla, ut dignissim nulla. Aenean eget tellus vel libero venenatis vestibulum. Maecenas magna sapien, mattis at pharetra eu, iaculis sed magna. \n\n"; code_format($text, $images); ?>
  5. I'm still looking for a solution if anyone else has some fresh eyes to lend me please?
  6. $_SERVER['HTTP_REFERER'] it is not very reliable though
  7. The php way would be something like this <?php if ($_POST['action'] == 1) { /* DO SOMETHING */} else { /* DO SOMETHING ELSE */ } ?> <form name="form1" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input name="action" type="hidden" value = "1"> <input="submit" name="submit" value="submit"> </form> <form name="form2" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input name="action" type="hidden" value = "2"> <input="submit" name="submit" value="submit"> </form>
  8. What you are hoping for will require some javascript. PHP is executed on the server, javascript is executed in the browser. Or you can have the form's action point the the same page...then have a hidden input on each form. the hidden input will give an if statement or a switch to choose a peice of code to execute
  9. has anyone used joomla or mambo? you have a list of images..then you place a tag in your article...the list of images will go in order of those tags you place in your text. thats what I am trying to accomplish if that helps.
  10. I have tried to replace each tag one at a time, but it replaces them all with the same image. foreach ($images as $key => $value) { $str = preg_replace ('/\[img\]/is', $value , $str); echo $key."|".$value."<br />\n\n"; } I don't know what else to try?
  11. for the resizing portion of your problem you can start with imagecopyresized(). the manual has good documentation on how to use it.
  12. Here is the output of what I have...It works fine, I accomplished my goal... My bbcode tags are replaced with html tags, including the image tags... Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin sit amet risus enim. Nunc urna libero, porta eu tristique vel, porta vel est. Phasellus imperdiet commodo mauris sit amet eleifend. Fuscemi sem, suscipit sed rhoncus a, egestas sed nisl. Phasellus cursus eleifend congue. Vestibulum sit amet ante blandit massa aliquam porta. <img src='1.jpg' /> Nulla lacinia purus non justo iaculis ultrices. Nunc sollicitudin odio sed ligula hendrerit vel euismod turpis porttitor. <strong>Pellentesque suscipit</strong>, tellus quis gravida blandit, quam tellus posuere ante, ut egestas odio erat nec augue. Praesent hendrerit mi sed metus suscipit hendrerit. Sed non ullamcorper ante. Phasellus nibh mauris, placerat at sodales non, tempus id dolor. In ullamcorper urna purus.<br /><br /> Duis suscipit leo eget eros accumsan in auctor dui placerat. Quisque id dui quam, porttitor varius nisi. Maecenas vestibulum sagittis neque vitae blandit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed tortor mi, sodales vitae fringilla commodo, pellentesque sit amet nisl. Proin aliquam metus in velit blandit at molestie sapien dapibus. Ut sollicitudin lectus id massa suscipit lacinia. Sed ante felis, ultrices et iaculis nec, tristique at sem. Donec a augue et orci convallis semper. <img src='2.jpg' /> Vestibulum mi neque, accumsan vel suscipit quis, cursus quis lacus. Vivamus vulputate cursus odio, eget cursus urna consequat vitae. Cras laoreet iaculis quam commodo malesuada. <em>Praesent scelerisque laoreet nisl, eu tempor diam gravida et. Ut dictum sodales nisi</em>. Morbi viverra ornare porttitor. Ut pretium urna sed arcu venenatis et ultricies elit aliquam. Ut ut sollicitudin neque. Praesent orci magna, convallis et cursus vitae, ornare eget erat. Integer id est nec odio pulvinar tincidunt.<br /><br /> Praesent id sapien libero, sit amet tincidunt lorem. Quisque volutpat nisi a tortor fringilla et scelerisque enim dignissim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse non mollis nunc. Duis vel molestie magna. Praesent nisi elit, posuere vel convallis id, mollis vitae dui. Vivamus aliquet semper dapibus. In ultricies molestie convallis. Vivamus hendrerit tellus venenatis lorem vulputate at interdum sapien dictum. Sed urna neque, facilisis et posuere nec, sodales rutrum nisi. <img src='3.jpg' /> Suspendisse potenti. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; <u>In id mi eros, a iaculis arcu</u>. Maecenas consequat consequat congue. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam blandit, nunc vitae sodales rutrum, nisi neque viverra massa, vulputate venenatis elit lacus vitae arcu. Curabitur at ante ipsum. Quisque sodales mauris a arcu sodales nec fringilla lacus interdum. In in lobortis dui. In malesuada, diam ac auctor interdum, massa nibh scelerisque augue, et tincidunt lectus purus eget lectus.<br /><br /> Aliquam adipiscing tincidunt posuere. Suspendisse non purus nisl, at dapibus sapien. Maecenas posuere urna ac nibh scelerisque malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Phasellus sed nibh tortor, ac porta orci. Mauris ac turpis vitae libero vehicula pellentesque. Quisque vel urna sed magna pellentesque varius a et ligula. Proin ultricies magna at nibh auctor imperdiet. Nullam sed erat mauris, id laoreet augue. Pellentesque enim est, accumsan varius mattis ac, convallis sit amet velit. Cras nulla risus, laoreet ac consectetur ut, tristique ac lorem. Curabitur scelerisque elit eget nunc eleifend eu fringilla nibh porttitor. <img src='4.jpg' /> Sed ullamcorper vestibulum orci, vel interdum turpis semper non. Quisque id malesuada velit. Praesent a est nulla, ut dignissim nulla. Aenean eget tellus vel libero venenatis vestibulum. Maecenas magna sapien, mattis at pharetra eu, iaculis sed magna. however... I am trying to figure out how to automatically insert these jpg's from the images array without hard coding them using their keys. $str = sprintf($str,$a.$images[0].$b,$a.$images[1].$b,$a.$images[2].$b,$a.$images[3].$b);
×
×
  • 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.