-
Posts
1,832 -
Joined
-
Last visited
-
Days Won
3
Everything posted by salathe
-
Rounds a number up to an integer; e.g. ceil(2.345) rounds up to 3. Full info on the ceil manual page.
-
Very similar questions seem to pop up here very regularly. If you're using PHP 5.3 then you can use strstr with its handy 3rd parameter, or you could use any number of other string-functions such as strtok.
-
Show us what you've tried and we can go from there.
-
$number = 21; echo round_up_to_ten($number); function round_up_to_ten($i) { return (int) (ceil($i / 10) * 10); }
-
How do I change boolean output from query to text value in table
salathe replied to capella07's topic in MySQL Help
You could use the ternary operator like ... ($row['isOnTime'] ? 'Yes' : 'No') ... -
As PFMaBiSmAd said, there is a space character at the end of this string which (I'll make an educated guess here) should not be there. Change the value in the database to not have that space and that should be your issue solved. It's probably worth making sure no extra spaces are appended/prepended to paths when inserting them into the database initially.
-
Cross Domain Proxy : Blank XML returned when url contains space
salathe replied to swarnendude's topic in PHP Coding Help
Look to urlencode-ing the value so that non-URL-safe characters are not sent along as part of the URL. -
"How beta is beta" is irrelevant since the version PHPFreaks is running on isn't a beta: it's a release candidate. Running the RC allows any last-minute bugs to be discovered and squashed before the full release, that's the open-source way. Sure, perhaps best not putting a mission-critical part of a business on this version but a PHP forum... sure.
-
Difference between stdclass object and XML
salathe replied to SchweppesAle's topic in PHP Coding Help
In short, no. SimpleXML is for loading and manipulating XML files and stdClass objects are the 'default' PHP object which do not need to be "loaded" by any functions, they're entirely unrelated to XML and SimpleXML. -
Reading through your post I was thinking, "a new speaker system" and was happy to see that on your list of ideas.
-
You could also just use file_get_contents on the full URL; like with cURL but only one line of code.
-
Hi Damien welcome to PHPFreaks. It's good to see that you're learning PHP & MySQL, best of luck with that. I'll also say "hi" to you on IRC in a second. :-)
-
Is the PHP only used to send along the header? If so, don't use any PHP at all and let (or make) your web server provide the correct content type header for JavaScript.
-
How exactly are you getting this value? If you're using a form and the traditional $_GET/POST variables, there should be no need to urldecode the values as they are already urldecoded automatically.
-
Here's another way of doing it: $array = array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D'); $new = array('c' => $array['c']) + $array; print_r($new);
-
That attached file is essentially a different representation of the contents of a php.ini configuration file. The file does not 'compile' any error logs nor does it email anyone... did you perhaps attach the wrong file?
-
You're welcome. I do tend to find that folks 'forget' about the range of array (and same for string) functions and just need reminding. If you don't mind, I've marked this thread as "solved" (though that's normally your responsibility) -- if you think it's not, please do click the button to mark it not solved.
-
Hi Ryan, welcome to PHPFreaks! Finally, Edinburgh is defrosting.
-
$input = 'hello#hello'; $hello = strstr($input, '#', TRUE); // PHP 5.3+ $hello = strtok($input, '#'); // PHP 3+
-
Since glob returns an array, you can use array_slice to get a specific slice of it (e.g. $a_imgs = array_slice($a_img, 0, 10); to get the first 10 files).
-
Hold on a second, could you let us know what gives you this impression? As far as my limited understanding of copyright law goes, all works are protected by default. If the work is to be public domain, the owner has to say so somewhere. Just because some code contains no license or copyright claim does not (especially does not!) mean you can "steal" (in the truest sense of the word) it. As for the original question; I certainly would claim to be the composer of a piece of music if all I did was change a few notes around. For code to be mine, I believe it has to be the product of my own mind (and fingers).
-
You'll need to work directly on the array: foreach ($info as $key => $value) { // Unset the old key/value pair unset($info[$key]); // Make new key $key = $key . (number_format($value/$total,0)) . '%'; // Add in the new key/value pair $info[$key] = $value; } You could also just build an array of new keys and use that when constructing the URL: foreach ($info as $key => $value) { $percent_keys[] = $key . (number_format($value/$total,0)) . '%'; } // ... echo implode('|', $percent_keys); // in place of "echo implode('|',array_keys($info));"
-
It can be difficult to spot the links sometimes especially if you're not expecting a link. Some underlines wouldn't go amiss.
-
Yay <?php phpinfo();