php

Help with regular expression

I need a regular expression that, given an ingredient line, will tell me the quantity of that ingredient. Here are some sample values: 8 ounces semisweet chocolate 6 eggs 3/4 cup sugar 1-tablespoon espresso powder 1/2 cup Dutch processed baking cocoa 1/4 cup unsweetened cocoa 1/2 cup confectioners' sugar 2 cups heavy cream 2 to 4 dried...

How to UPDATE a certain row OR RETURN FALSE if it doesn't exist?

How to do it in one query? ...

Clone div and rename element ids incrementally

Ok lets say I have div with form elements inside of it. I want to be able to clone that div with a button click using jQuery and add a version 2 of the form, so ALL of the element IDs will increment by 1 in their name. <div id="card"> <!-- PART 1 --> <h1 class="card_build">Build your card options:</h1> <select id="country...

Close tags from a truncated HTML string

I have inherited a site with a news section that displays a summary of the news article. For whatever reason the creators decided that displaying the first X characters of the article would be fine. Of course this very quickly led to the summary being something like: <p>What a mighty fine <a href="blah">da <p>What a mighty fine and warm...

PHP: SELECT and filtering in 2 tables at once

I would like to make a list to show the user´s friends, that are online. users id | firstname | lastname | last_access users_friends uID | bID | type | accepted That is how my tabels look like. Firstly I have the user´s id in $USER. The $USER´s id is stored in a row, in users_friends, at column "uID". bID is the id of the friend....

A PHP MySQL Error which I just cannot work out - help please

Hi guys - extreme novice here playing with PHP/MySQL trying to teach myself online but can't figure this out for the life of me... I have been following a PHP tutorial at http://www.keithjbrown.co.uk/vworks/php/php_p5.php This page is at tasmanianracing.com/horses.php I'm getting the following mysql error: You have an error in you...

Facebook API and Json with PHP,how to?

Hi friends, https://graph.facebook.com/search?q=India&amp;type=post i am using the above api of Facebook and i am getting following Output { "data": [ { "id": "501585456_163489377008878", "from": { "name": "Ian Robinson", "id": "501585456" }, "message": "\"Media subdu...

Is there something like PyFlakes for PHP?

Pretty straight forward question. I'm quite happy with my simple text editor but sometimes it'd be nice to run something like PyFlakes on my code before running to check for any obvious errors like undeclared variables or syntax errors. ...

Pass multiple values in link

I have three values that I want to pass via a link, but don't want them visible in the URL. ...

A good line-graph generator for my benchmarking?

To learn more about a language I rewrite some of the core functions, or compare basic speeds of each set of functions per problem to see what is more suited in real world situations. Other than an ugly online line-graph generator which often only allows one or two series, I cannot find anything that would suit what I need. Do you know ...

Monthly Archive posts by category-wise

I have set my monthly Archive page (Archive.php) as like this : Monthly Archive When clicking on any MONTH, the result will show all the posts for that particular month as below: Post title-1 ------ Category-1 ------ Author name Post title-2 ------ Category-1 ------ Author name Post title-3 ------ Category-1 ------ Author name Post tit...

Regex for Parsing Tweets for Links

I found a link in a tweet that my current regex won't parse and I can't seem to figure out how to get it working (probably due to my ineptness with regex). Here's the current code: preg_match_all('@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)@',$description, $matches, PREG_SET_ORDER); And the Tweet that won't p...

Move class attribute value to php variable

We have variable $menu with HTML inside (there is no loop, it comes from a function). On echo it gives the code like this: <ul id="menu"> <li id="some-id" class="many classes one"><a href="#">text</a></li> <li id="some-id" class="many classes second active"><a href="#">text</a></li> <li id="some-id" class="many classes thre...

Dynamically access an object property array element in PHP

I have an object, that I would like to interact with dynamically. I would like to rename the game1_team1 in: $default_value = $individual_match->field_match_game1_team1[0]['value']; to be game1_team2, game2_team1, game2_team2, game3_team1, etc. Based on the loop they are in. I have tried: $dynamic = 'field_match_game'.$i.'_team'.$j;...

Recognizable numbers using PHP

Hi all, I’m trying to extract some numbers ranging from 1-99 from a picture. I’ve tried several OCR methods using PHP, but eventually my script will fail, since the numbers occasionally is rotated 5% to the left or right. This making the picture not being recognizable. View example of my numbers: http://d.imagehost.org/view/0373/screen...

How to call an swf file using php?

I'm using the zend framework. From within my phtml file, I am trying to call a link to a swf file that is outside of my web directory. The code for this link is: <?php echo getcwd(); ?> <object width="550" height="400"> <param name="movie" value="somefilename.swf"> <embed src="/message/get-file/messageId/<?php echo $this->messag...

how can I setURL friendly urls in wordpress

Hello guys How can I set SEO friendl urls like http://bodyharmonynutrition.com/eating-a-heart-healthy-diet/ in my site ? Thanks a lot for your time ...

How can div wrapper grow with img size?

Hi, How can div wrapper grow with img size? <div style="width:900px;"> <div style="width:100%;"> <div>some text......</div> <img src="<?php echo $imageSrc; ?>"/> <div>some text......</div> </div> </div> Thanks ...

What is the best framework size for PHP?

I have created my own framework for my websites and it is around 410 KB. What should be the best framework size and does code size really matters? If there are some functions which are not being utilized on a page removing them will make any difference in page loading? ...

PHP cURL get content with accented URL

Using cURL with an accented URL, I cannot get content if CURLOPT_RETURNTRANSFER = true. Example: $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, "http://fr.wikipedia.org/wiki/Été"); curl_setopt ($curl, CURLOPT_RETURNTRANSFER, true); $html = curl_exec ($curl); echo $html; $html is empty, does someone have a solution ? ...