Jump to content

Kane250

Members
  • Posts

    230
  • Joined

  • Last visited

Everything posted by Kane250

  1. Thanks for the suggestion. That's what I was originally doing and it was not removing it, which s why I was so confused. Those numbers were single numbers separated by the , . Anyway the solution above worked out, bu thanks for helping out.
  2. Ok, that totally worked, ha. I used the first one: $numbers = array_map('trim', explode(',', $numbers)); and it fixed it. I still don't totally get it, but hey, great! Thanks for your help!
  3. If there would only be space at the beginning and end after exploding into an array, then why else would I be getting white space in the middle of it? That's my main problem. The white space is coming from the soft returns in my list of numbers. ex: 345,876,987 922, 761 When echoed from the array, the numbers would look like this: 345,876,987, 0922,761. Notice the space?
  4. Thanks for the response. I'm really confused about what array_map does, and I thought trim() is just to remove whitespace at the beginning and end, no? I originally had this set up using foreach t make the array and had the same problem.
  5. This is probably the dumbest question, but how can I get rid of all whitespace from an array I am creating from a text file? I have numbers in a text file, separated by , and at the ends of some lines, I have done a soft return because my text editor does weird stuff with indenting when I don't. However, when these numbers are pulled through later on, there is a space before some of the numbers. Here is what I have been trying to use. Doesn't work. Any help is very much appreciated! $numbers = file_get_contents('sample.txt'); $numbers = str_replace("\r\n","",$numbers); $numbers = explode(",", $numbers);
  6. Well you can use foreach to get the data as well...that's what I use more often. I don't really know what you're doing with the data, but you're gonna have to loop through it somehow as far as I know.
  7. That did not work either, but I did just try urlencode() and it converts the apostrophe to this: %26%238217%3B and somehow, it fixes my problem! Is that the html equivalent of an apostrophe or something?
  8. Yeah that is how it is supposed to function, remove the apostrophe from the actual link but leave it in the visible title. I have no idea why it wont work in Wordpress. The apostrophe always shows up in the url..
  9. Hey there, So, I am modifying wordpress lately, which is all PHP, and I'm trying to change tags in URL's so they do not contain spaces or apostrophes. This was screwing up my URL's. So here is what I did: <?php $title = get_the_title(); $title_link = str_replace(" ", "_", $title);?> <h2><a href="?tag=<?php echo str_replace("'", "", $title_link); ?>"><?php echo $title; ?></a></h2> get_the_title() if you're not familiar with Wordpress just returns the title of a post, so in my case it's just a word of a couple words. The above worked for anything that had a space, and added an underscore as requested, but it will not remove the apostrophes and I don't understand why. Anyone see a good reason why this would not work correctly? Thanks for any help in advance. I've been stuck on this one for days...
  10. Thanks guys. As I mentioned in my post, I had ZenPhoto...the thing was, I don't want something that does that and more like Zen does. ZenPhoto was not easy to implement into existing html, and it just had too many features that weren't going to be utilized. Thanks for the simple gallery link as well, but that doesn't have the feature I need, an uploading interface for a user. Anyway, I ended up using Plogger (www.plogger.org). It was the closest thing I could find to a basic but nice gallery / cms system, and wasn't too hard to implement. I recommend it unless anyone knows of anything better of course.
  11. Here is an example of what I'm working with..I know it's totally wrong, but I'm just trying anything right now.. $unique_entries ( 0=> "one sentence", 1=> "second sentence", $compare_array ( 0=> "a second sentence", 1=> "one sentence", else { print "we are at else"; foreach ($unique_entries as $testagainst){ foreach ($compare_array as $database_entries) { similar_text($test_against, $database_entries, $how_similar) if ($how_similar < 75) { $unique_entries[] = $test_against; } } } Ideally in this example, it would not pass either, even though "second sentence" is not the same as "a second sentence" because of such close similarity from the array connected to the database.
  12. Can anyone provide an example of how I might use similar_text between two arrays? I want to take one array of entries, and look for matches in an array from MySQL that are within a certain % of similarity so that I can remove those entries before inserting into MySQL. I can't find a single example online that compares two arrays with this function. Any help is really appreciated. I really need to figure this out ASAP. even if you could just explain the logic of how I would have to write it! Thanks!
  13. Hi, I did find search results on this - but they don't seem to do what I want to do, and could really use a hand getting this code started if anyone is familiar with this function. Basically, I am taking a paragraph of text, splitting it up into sentences and into an array, and inserting each one by one into a table. However, there is a high probability of very similar text or exact text to be re-inserted over and over, so what I want to do is use the levenshtein function to check against the database for similarity and only allow it to insert if it's a certain percentage different (or however you define it). Basically, I know that I need an array of what's already in my database, and that the function should compare the array of sentences against that array, but I don't really get how to use this function to make the decision of it passing through or not... Any help is very much appreciated! Here is the relevant code I want to add this too.. $para1content = "these would be sentences. More sentences."; $para1exploded = (split('[.!?] ', $para1content)); foreach ($para1exploded as $content) { $query = "INSERT INTO `$value` (`text`, `key`, `added_at`) VALUES ('$content', '$key', CURRENT_TIMESTAMP)"; if (!mysql_query($query,$conn)) { die('Error=' . mysql_error()); } };
  14. Thanks guys, I actually ended up using split('[.!?] ', $variable), which worked well and also allows sentences to be types in with additional periods like this... However, in a normal sentence with just one period, it is still omitting that period. Anyway I can have it include a period that ends a sentence, but still include them when someone types extras?
  15. Sorry for the delayed response. This looks good. I'm gonna try this today and see if it does what I need it to! Thanks!
  16. Hi, I have searched the net for days and tried implementing quite a few solutions, and am not happy still. I'm looking for a very bare bones app to display images on a site that will allow the website's owner to add their own photos. I just want to use my own html - not have a gallery on a page that looks different from the rest of the site. Everything I am finding has all these extra features I don't need, and it's really aggravating. I have tried Zen Photo and Gallery so far and both seem to need really excessive modifications to accomplish this. I would love to just have lightbox launch the photos so everything is one one page, and then have a really simple login somewhere that the owner can just upload an image and a caption. No bells and whistles... Does anyone know of something like this short of having to write my own?
  17. Hi, I'm using the following code to select a paragraph of text, and split the paragraph up into sentences, but it's far from working perfectly. Every time it runs, I am getting a trailing blank entry in MySQL. I'm also not getting the periods from the sentences. Any idea how I can fix this? Also, is there an easy reg exp that I could use so it will separate sentences by (. , !, and ?) and tell it to ignore multiple line endings like: ... or ?? ? //Collect data from paragraph and put into a variable $para1content = ($_POST['finalFirstPara']); //Separate data into sentences, spearated by (.) and put into an array $para1exploded = (explode('.', $para1content)); foreach ($para1exploded as $content) //This iterates through the selected exploded array { $query = "INSERT INTO `para1` (`text`, `key`, `added_at`) VALUES ('$content', '$key', CURRENT_TIMESTAMP)"; if (!mysql_query($query,$conn)) { die('Error=' . mysql_error()); } }; Thanks in advance!
  18. Wow, so even when pulling a list of a few hundred entries at a time from within thousands, it's still pretty quick? I had no idea. Do you agree then that making a ton of new tables is a poor method?
  19. Ohh cool, this is a much better solution, thank you! Yeah, I'm still learning about security with forms...not looking forward to reg exps... ha Thanks again!
  20. hmm, might be an idea, except that textareas look different in different browsers, and even just the corner piece of a textarea that allows for resizing in some browsers, will mess up the design. Basically, it is supposed to look like an image... good thinking though, I can see what CSS tricks there are if nothing else!
  21. strictly for design purposes, it cannot look like a text field. It has to look like static text (even though ajax will be allowing it to be edited in place).
  22. Thanks, that makes more sense. One last thing then. The value that is being passed into the div is from a POST variable coming from the page before it. People are actually going to be able to edit the text in this div (with ajax) eventually, so how can I set that up so the hidden field is not setting its value to the original POST value? ex: Here is what the div is getting now from the previous page. <div class="finalPara" name="finalFirstPara"> <?php print($_POST['firstParaText']); ?> </div> Since the text will likely change on this page, using this code: <input type="hidden" name=<?php $_POST['firstParaText'] ?> > will not allow me to pass the updated text. Get me? Any Idea?
  23. Hello PHP Gurus... Is there any way to pass text into PHP from a div? I have been trying to set up divs inside a form which posts to the page, but since a div is not an input type, maybe this isn't possible? I have the div name and id's set correctly and PHP is looking for their POST, but I just keep getting blank entries. Am I being a moron, or is this not something PHP can do? Thanks!
×
×
  • 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.