
silkfire
Members-
Posts
569 -
Joined
-
Last visited
Everything posted by silkfire
-
Do you want 50% of the values to be in the left DIV and 50% in the right DIV?
-
The "var" keyword is deprecated and you should not use it. You forgot a $ sign in front of your variable. I'm quite sure you don't need that variable declaration there are at all. At least change it to $unitsPerCase = 0.
-
Use array_intersect: All elements which the two arrays share will be part of a new array.
-
Export it as an XLS. You will not have control of width with a CSV file, it's pure data.
-
If you read it row by row, column by column then the data will appear in the order you specified. Show us your attempt to code.
-
Well actually what I showed you are the keys. What is your suggestion? Is there a way I could make a generic function where I can enter arguments for size of the groups and which Nth number to pick?
-
It will contain strings, does it matter? But they have to be grouped together logically, like I showed.
-
How do you solve this problem? I have a flat array that I need to transform into a 2D array where every fourth item is group together and contains 4 items. From: array( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ) To: array( array(0, 4, 8, 12), array(1, 5, 9, 13), array(2, 6, 10, 14), array(3, 7, 11, 15) ) I'm sure there's some easy solution... Note that I need to transform it, not create one from scratch.
-
Hmm... I just took a look at the structure of your site and it's a mess but it's not your fault, I know. If you use Chrome or Firefox use the Developer tools to see the underlying structure of the page that's imperative in order to know how to process the page. Do you want to extract the name of the product, price and link, and image? All those values are in different cells when they should've been put in the same so you have to account fo that later on.
-
There are many ways to do this, depending if I understood you right. How do you want the resulting array to look like? Do you want to flatten the array? Or do you want to consolidate the array?
-
Funny. When you right click the images on that Tigerfitness site it says "Our images are copyrighted." But I guess it's your own store so you can do whatever you want with them
-
TCombs in this case you need a DOM Parser, don't use Regex for webpages. If you don't know what a DOM parser is, it's a PHP class that gives you access to all the nodes in an HTML page in a structured, logical way - then you can pick anything you want and save it anywhere you want =)
-
I think you should try harder. Also your request is very unclear about what it is you want. Anyhow, to extract the Asset node (there are two), you do like this, the number in the bracket denotes which of them you want (in order of appearance in the file, starting from zero): $xml = simplexml_load_file('goog-20101231.xml'); $namespaces = $xml->getNamespaces(true); echo $xml->children($namespaces['us-gaap'])->Assets[0];
-
Your link is broken =/
-
You can copy the function into your own code, maybe?
-
Use "echo mysql_error();" to find out the exact error message, please.
-
Want a solution? Do this: $is_sera = str_replace(array('\'', '%', '?'), array('"'), $is_sera);
-
Every PHP regex expression needs to have a delimiter character. It's used so that after it you can put flags to manipulate your regex (it's like options of sort). Common practice is to use a rare character, something that's not bound to occur in the expression itself, f.ex. "%", "/" or "ยค". Correct would be: $is_sera = preg_replace('%\?%', '', $is_sera); Just a warning. You have a very simple regex that you dont need regex for. Use str_replace instead.
-
need help with a file path to my css file
silkfire replied to ricky spires's topic in PHP Coding Help
any errors? -
AhhhH!: Removing everything between <div id="admin-menu">...</div>
silkfire replied to ultrus's topic in Regex Help
You need a DOM parser. Regex wouldn't know how to find the matching DIV if there are DIVs inside your HTML code (which I'm sure there is) -
Never use strtotime('now') it's completely redundant. strtotime always assumes "now" which in PHP is written as the return of function time(). $sunday = date('Y-m-d', strtotime('last Sunday', strtotime('last Saturday'))); $saturday = date('Y-m-d', strtotime('last Saturday')); $firstday = date('Y-m-d', strtotime('next Sunday', strtotime('last Friday', strtotime('first day of last month')))); $lastday = date('Y-m-d', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))); echo"$sunday<br />$saturday<hr />"; echo"$firstday<br />$lastday"; Not sure though those are the dates you wanted. See my previous code.
-
Also your retrieval code can be shortened, most of the cURL options are redundant in this case. Plus POST only the minimum required POST fields: $ch = curl_init('http://app.alliedinsurance.com/find_agent/calcpage4_1_popup.cfm?RequestTimeout=180'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_REFERER, 'http://app.alliedinsurance.com/find_agent/find_an_agent_popup.cfm'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "State=&City=&ZipCode=$_POST[zipcode]"); $html = curl_exec($ch);
-
Mate if you would bother to turn error reporting on you would see 2 obvious errors. You misspelled two of the cURL options. CURLOP_REFERRER should be CURLOPT_REFERER CURLOPT_HEADER_OUT does not exist, you already have CURLOPT_HEADER. Fix that then you should see it works.
-
And here's the code to generate that table of yours, for testing purposes: for ($i = 2; $i <= date('n'); $i++) echo date('M', mktime(0, 0, 0, $i - 1, 1)), ".\t", date('n/j', strtotime('+2 days', strtotime('last Friday', strtotime('first day of this month last month', mktime(0, 0, 0, $i, 1))))), '-', date('n/j', strtotime('+1 day', strtotime('last Friday', strtotime('first day of this month', mktime(0, 0, 0, $i, 1))))), '<br>';
-
Here's the code to generate a period. $dates = array( date('Y-m-d', strtotime('+2 days', strtotime('last Friday', strtotime('first day of this month last month')))), date('Y-m-d', strtotime('+1 day', strtotime('last Friday', strtotime('first day of this month')))), ); print_r($dates); Good luck!