logs archiveIRC Archive / Freenode / #php / 2015 / August / 28 / 1
hanshenrik
yeah ill make it persistent :p
verodeb
i think i forgot to make sure both apps were connecting with ssl in the benchmark, but anyway PDO was running really fast and it was spiting a query of 1530rows
AcidReign
verodeb: ssl? are you connecting to DBs over a public network?
verodeb: that's a performance killer, your DB should be as close to your webserver as possible...
verodeb
well no u re right it is a LAN so no need for ssl, anyway i should make sure ssl is off then
pmcgovern
I want to search an array by a sub-array value.. is there an easy way to do this? simplified example here: http://pastebin.com/CeLzf7xq
verodeb
pmcgovern: u want to find by codename?
pmcgovern
by the value of codename - so grab the parent array(7 => []) that has a 'codename' of 'team'
verodeb
well if u store in an ordered way the codenames then u could do a bin search or somethin
go to the half of the the entire array check the if the codename u are looking for comes before or after alfabetically
pmcgovern
but regardless, i'm stuck with iterating through the array
         

verodeb
then divide agian by 2 the interval, and narrowing again and again until u find it
it would be faster
O(logn) complexity
publow
I have two timestamps. 1394755200 & 1394708400. in GMT+0 one is 13 March, other is 14 march. But in my timezone (GMT+13) they are both 14 March. How can I compare timestamps like this in my timezone +13 & check if the calendar day is greater /equal/less. I don't care about the time of day
verodeb
if the array length is always small u can use foreach http://php.net/manual/en/control-structures.foreach.php to cicle through the entire array and look for what u want
AcidReign
!+array_filter
php-bot
array array_filter(array input [, mixed callback]) - Filters elements from the array via the callback. - http://php.net/array_filter
AcidReign
it's a little quicker than a loop, but it visits every element
OTOH with a loop you could break once you found the element
if the value of the inner array is guaranteed to be unique, you could build your outter array keyed on that value, then just do $a[$k] ...
and otherwise still use it as an ordered list
Suppish
Hello?
AcidReign
pmcgovern: ^
Suppish
Oh cool, people are alive here.
AcidReign
Suppish: nope, only zombies here
Suppish
Apparently I am suppose to come here to ask php related questions.
AcidReign
and robots
Suppish
Better not be nazi zombies.
AcidReign
nope, just nerd zombies, and robot geeks
Suppish
Marginally better I guess.
AcidReign
neither have ever invaded Poland
verodeb
lol
Suppish
At least not yet.
njasm
maybe tomorrow, who knows
:|
verodeb
dont make fun about such an event in history, respect :X
         

njasm
indeed!
Suppish
Eh. I guess.
So yeah, I have a question about php xml parsing. I don't suppose you guys mind? I was told to come here to ask.
AcidReign
Suppish
It's something more specific than that.
http://bluecollargames.net/SummonersCodex/DungeonData.xml
Trying to parse this file for data
I can read the Name with echo $xml->Dungeon[0]->Name;
However I can't seem to read deeper than that.
AcidReign
well then I suggest DOM
Suppish
=/
DOM?
AcidReign
rather than XMLReader or XMLParser as those are both stream parsers, and take more effort
DOM (document object model) works similar to javascript's DOM
pretty much the same thing
Suppish
hmm
publow
anyone got a thought on the timestamp comparison?
Suppish
Can't say I have ever used/heard of DOM before.
AcidReign
Suppish: so you've never used javascript?
Suppish
I guess I'll read up on it.
Nope.
AcidReign
oh hmm
Suppish
Always been a C guy.
Currently learning php
Fun stuff actually.
njasm
AcidReign
usually people coming here have done at least minimal webpage stuff and have seen a little javascript
Suppish
new to the whole web-programming fiasco.
So sorry if I am scrubbing up the place.
AcidReign
Suppish: well with the DOMDocument you can iterate through nodes, and recursively travel down into child nodes, or you could use a series of XPath queries to extract certain elements
Suppish
So with the simplexml parser thing I can't go through the nodes?
From what I can tell a line like ($xml->Dungeon[0]->Wave[0]->Card[0]->ID;) doesn't work.
AcidReign
SimpleXML is a trap... it's not that simple, it just wraps DOM...
most people dislike it
Suppish
Ah.
AcidReign
I've used to successfully, but it has issues
its really only useful for very simple xml documents
waerloga
I think it's better named for the complexity of xml you would use for it
AcidReign
i.e. something that could just as easily have been a json document...
njasm
my personal experience when i used SimpleXML wasn't bad, you just need to udesrtand how to use it.. and the php.net doc is invaluable for that.. check the examples..
AcidReign
don't use it if your xml uses namespaces or a schema, but it's fine if its basically just <xml> <key1>value1</key1> <key2>value2</key2> </xml>
publow
are there any known bugs with php datetime and setting timezone?
AcidReign
publow: I don't know any
publow
i'm experiencing an issue with that regards
Suppish
That's what I have noticed through testing.
AcidReign
Suppish: one thing to watch out for with simplexml is that every object property is an instance of simplexml, and what appears to be a string is actually an object with __tostring() and that can cause some headaches. basically always cast if you don't want trouble: $key1 = (string)$xml->key1;
Suppish
I see.
Err, how do I pm people on IRC?
publow
Suppish
That redtext thingy.
AcidReign
Suppish: /msg username foo bar
publow
Is it something I'm missing or is there a different way
AcidReign
publow: "The $timezone parameter and the current timezone are ignored when the $time parameter either is a UNIX timestamp (e.g. @946684800) or specifies a timezone (e.g. 2010-01-28T15:00:00+02:00). "
publow
doh
wfpkhc
if i have a number in a querystring and i use $_Get to retrieve the value - what is the correct way in php to check that the value is a valid integer - is it if( ctype_digit( $strQueryStringValue ) )?
publow
i'm trying to compare timestamps at date level only. ie. not time
what are my options
wfpkhc
publow, - http://stackoverflow.com/questions/961074/how-do-i-compare-two-datetime-objects-in-php-5-2-8
AcidReign
publow: first thing you should understand is unix timestamps are always in GMT (+000)
Suppish
Hmm, I seem to have it working now.
wfpkhc
@my question - http://stackoverflow.com/questions/2012187/how-to-check-that-a-string-is-an-int-but-not-a-double-etc
AcidReign
wfpkhc: $val = filter_input(INPUT_GET, 'value', FILTER_VALIDATE_INT);
that will either return an int, or null if the value was not a valid integer value that PHP understands
« prev 1 2 3 4 5 6 7 next »