- Strength to Increase Rep
- +11
- Strength to Decrease Rep
- -2
- Upvotes Received
- 176
- Posts with Upvotes
- 142
- Upvoting Members
- 80
- Downvotes Received
- 8
- Posts with Downvotes
- 8
- Downvoting Members
- 5
- PC Specs
- 15" Macbook Pro (2011), OS X 10.7.
Re: Or you could use preg_split to work with commas, semi-colons and spaces. | |
Re: You missed a semi-colon at the end of line 7. | |
Re: This example is taken from PHP.net > setcookie [CODE] <?php // set the cookies setcookie("cookie[three]", "cookiethree"); setcookie("cookie[two]", "cookietwo"); setcookie("cookie[one]", "cookieone"); // after the page reloads, print them out if (isset($_COOKIE['cookie'])) { foreach ($_COOKIE['cookie'] as $name => $value) { $name = htmlspecialchars($name); $value = htmlspecialchars($value); echo "$name : $value <br />\n"; … | |
| Re: I'm not 100% sure what it is you're trying to do. If you're trying to find all of the consonants in a given string, what about something like the following. This will include the same letter in $matches multiple times, if it is matched multiple times. To get unique consonants … |
Re: How about something outside of the box: $array = array(3, 5, 2, 5, 3, 9); $duplicates = array_duplicates($array); function array_duplicates(array $array) { return array_diff_assoc($array, array_unique($array)); } | |
Re: It really isn't clear from the code you've posted what your starting array structure or desired finished array structure should be. At a guess, you can do the following: $array = array(); $array['key1'] = 'one'; $array['key2'] = 'two'; print_r($array); /* array( 'key1' => 'one', 'key2' => 'two', ) */ If … | |
Re: Hi, Have you considered saving the Excel data as a CSV file, then reading the content of the file into PHP using file_get_content. You should then be able to explode the data by the comma symbol or something I am sure. What do you think? R. | |
Re: [CODE] $strText = file_get_contents( 'file.txt' ); $strFind = 'word'; $blMatch = false; if( preg_match( "/$strFind/", $strText ) ) { [INDENT]$blMatch = true; $strText = str_replace( $strWord, '', $strText );[/INDENT] } [/CODE] That will tell you if your word is found, and it will remove it from the string. R. | |
Re: I didn't think JavaScript running in a browser had access to the file system of a computer, as this would be a pretty huge security flaw. You could use PHP to create a text file on the server for the user to download. | |
Re: Okay, well it looks like you're most of the way there already. At the moment, you're uploading the file and using the original name of the uploaded file - that's the `$_FILES['file']['name'];` part. Instead, what you need to do is replace that with the new file name. E.g. $file_name = … | |
Re: Sounds like the array doesn't have an index with value 9. Try changing line 5 above to: <?php if(isset($url['11'][$i]['11']) && $url['11'][$i]['11']>0){ ?> And if you're using PHP conditional statements inline with HTML, I find the following statements easier to read than tracking brackets: <?php if(true): ?> <!-- Your HTML here … | |
Re: Hi, Surely the FTP will map your public_html folder, within which will be your PHP scripts. So can you not simply use the unlink function in PHP? Sorry if I am over simplifying the problem. R | |
Re: Hi, How about trying the following? [CODE=php] function convertDate($strDate) { return date('Y/m/d G:i:s', strtotime($strDate)); } [/CODE] R. | |
Re: Have you tried setting inline styles on the HTML body? | |
Re: You cannot upload a PDF file and then just read it's content. The file content is encoded. There are ways to extract the content of a PDF as plain text, but this won't work with images. Alternatively, you could use `file_get_contents` to read the content of the file, as is, … | |
Re: The click event is bound upon DOM ready state. If you change the DOM thereafter by adding new elements, these will not have the click event bound to them. You can either, rebind the click event (a little pointless), or you could use the on function. $(document) .on({click: function(event) { … | |
Re: This assumes that `time` is a MySQL DateTime field. DATE_ADD(`time`, INTERVAL 1 HOUR) | |
Re: URL encode is used to encode certain characters within a URL. It's not used to encode all characters and certainly isn't a means of encryption. 24 URL encoded is 24. | |
Re: I've used a foreach loop instead, but something like the following should work. $month = null; foreach($data as $row) { if(is_null($month) || $month <> $row['month']) { $month = $row['month']; echo "<strong>{$month}</strong><br />"; } echo "{$row['name']}<br />"; } | |
Re: Try: <?php if(! $viewee['name'] && ! $viewee['occupation'] && ! $viewee['education']): ?> <!-- Display your message here --> <?php endif; ?> <div id="container1"> <div id="friends-cta"> <?php echo $viewee['name']; ?> </div> <div id="friends-ata"> <?php echo $viewee['occupation']; ?> </div> <div id="friends-emp"> <?php echo $viewee['education']; ?> </div> </div> | |
Re: Is the file less than 50000 bytes and is there definitely not an error code set in the `$_FILES` array? Perhaps try adding an else to the if statement on line 6, to `var_dump` the `$_FILES` array. | |
Re: You should be able to view the local server of another computer on your network using it's network IP address. You can find this on Windows via the command prompt using `ipconfig -all`. If you're using multiple vhosts, you'll need to update the hosts file on the remote (non-hosting) machine. | |
Re: Are you using PHP 5.2 or above? If so, you could use to validate the email address as a whole: `filter_var('bob@example.com', FILTER_VALIDATE_EMAIL);` And then using strpos and substr extract the domain element and do a string comparison to restrict the domain. | |
Re: Post your database schema for the articles, category and sub category tables and the PHP code you already have. | |
Re: If I understand your explanation, you're asking how to redirect the user to the folder on their computer which contains the file they downloaded from your website? In short - it's not possible. Neither PHP or any front-end languages have access to the filesystem on the user's computer to do … | |
Re: >I have used the same code on another part of the site and it works perfectly. I don't see that you've reinitialised the `$files` array anywhere. It could be populated with the results of the last time you used the code. Add `$files = array();` immediately after line 4. | |
Re: Line 30 probably should not be commented out, unless I've overlooked a closing `</tr>` tag somewhere else. It may also be helpful if you could post a sample of your CSV file too, just to check that all lines contain the same number of comma separated values and no blank … | |
Re: What have you tried thus far? I would suggest you try one of the PHP XML libraries to parse the content from the feed. [SimpleXML](http://uk.php.net/manual/en/book.simplexml.php) is an easy one to start with. | |
Re: Hiding form fields doesn't really help improve security. However to create a hidden field, simply use the hidden type attribute: <input type="hidden" ... /> | |
Re: What have you got so far. Post your code. |