-
Posts
1,832 -
Joined
-
Last visited
-
Days Won
3
Everything posted by salathe
-
Show us the code that you're really using.
-
You could use preg_match to capture the number that you are looking for. If you have not used a regular expression before then tell us because it might seem like magical voodoo otherwise. if (preg_match('/[0-9a-f]{32}/', $buffer, $match)) { $value = $match[0]; echo "Found sid value $value"; } else { echo "Could not find sid value "; }
-
Awesome, a big congratulations to all however-many-folks-there-really-are! And a thank you to the 43.37 people who take the time to sign up every single day.
-
Are you sure that you really want a file full of ASCII 1s and 0s; that doesn't fit the normal use of the phrase "save it as binary data".
-
Switching from ereg_replace to preg_match syntax help
salathe replied to TheBrandon's topic in PHP Coding Help
preg_replace("/^\*/" ... will work. You were close earlier, just using the wrong function. Please take the time to read through the documentation (start here: PCRE functions) to familiarise yourself with this new set of functions. -
Switching from ereg_replace to preg_match syntax help
salathe replied to TheBrandon's topic in PHP Coding Help
See http://php.net/reference.pcre.pattern.posix (especially point 1 in the list). -
Andy-H, you might want to use the $options in the call to filter_var(). (P.S. If Andy edits his post, this won't make much sense.)
-
Have a read through the basic SimpleXML examples section of the PHP manual. Pay particular attention to example #3, and the short paragraph above it.
-
The math isn't particularly complicated, to see a description of the problem and existing algorithms visit PIP on wikipedia. Perhaps of more immediate benefit to yourself would be an existing solution in JavaScript to work specifically with Google Maps like a google.maps.Polygon.containsLatLng extension.
-
Using print_r or var_dump on a SimpleXML object won't be very helpful. If you want to see the XML, for example to make sure it was loaded, use $response->asXML(). For what it's worth, if the XML string could not be parsed for any reason then simplexml_load_string would return FALSE and one or more E_WARNINGS would have been printed with the specific problem.
-
You're both wrong, it was more like:
-
Just look at my post count, of course count does not correlate with skill!
-
Why do you want to start the key at 1? If it's a purely display thing, then just add one when printing the number.
-
No worries, already have done.
-
Finding the highest and lowest number in an array?
salathe replied to merylvingien's topic in PHP Coding Help
Problem number 1 Remove $row = @mysql_fetch_array($result); Problem number 2 How is your array structured (in PHP code, please)? It's easy to find the max, min and average values from an array. -
Check the PHP manual page for preg_match, which will tell you how to properly use that function. See http://php.net/preg_match
-
Did you just come to rant or are you genuinely interested in the topic?
-
Just for the record, it only effects namespaced classes. Classes not under a namespace (i.e. in the "global namespace") can still use constructors named after their class. That said, class-name-based constructors went out of fashion years and years ago with __construct() being much more preferred. Finally, the namespace separator is the backslash character (\) and not the solidus (forward slash, /) as thorpe used. In other words, Foo\IO\Http.
-
If you are using one of the JavaScript libraries/frameworks, there will likely be utilities to handle translating a JSON string into an object. We can't offer the library's way of doing things without knowing which one, if any, that you use. The old-school way would be to use eval(), and a better approach (which your library may already use) would be to use JSON.parse().
-
Is the old link going away or can we continue to use that?
-
Does explode() Negative Limit Make array_pop() Useless
salathe replied to phprocker's topic in PHP Coding Help
Sure, when $value is already an array. -
Firstly, parsing HTML documents with regex is a really hacky way of doing things. There are tools dedicated to making sense out of (HT|X)ML documents built in to PHP, like DOM. Secondly, you can use a "negative lookahead" within your regular expression to assert that javascript: doesn't appear where you don't want it: ~<a.+(href="(?!javascript:)(.+?)")~i
-
Is there any reason why you're choosing to use regular expressions to access the XML content rather than one of the numerous dedicated tools built in to PHP for working with XML? It would make life easier and make your code more reliable and easier to work with/understand. Let us know if you're up for that approach, or would just rather us help you to fix up what you have.
-
Hi Mike, welcome to the site. Look forward to seeing you around.