logs archiveIRC Archive / Freenode / #php / 2015 / July / 17 / 1
xochilpili
hi all
PsychoBoB
all hi
unnu
:D
xochilpili
i have a file that have inside [abc] some=>text [def] another=>text [ghi] again=>text, and im trying to put only the result of [def] another=>text and [ghi] again=>text; i tried with preg_match_all bu i only get [def] and [ghi] but no another=>text etc
theskillwithin
ok I think I got it working, but I think I need to make a validation test because sometiems I get error http://pastie.org/10297344
xochilpili
sorry by my english; this is what im trying to do: http://pastebin.com/ZJiHJU2k">http://pastebin.com/ZJiHJU2k
any hand?
sorabji
who made that file?
theskillwithin
xochilpili I am confused
xochilpili
about?
         

sorabji
what purpose does that file serve xochilpili ?
theskillwithin
xochilpili is there any way you could get [abc] some=>text on the same line?
xochilpili
sorabji, is a file from other software made it by someone else
theskillwithin, im going to post my test.php file
theskillwithin
if you could get them on the same line, maybe you could explode by newline
or consider instead of pregmatch, use preg replace "" to delete any data u dont want
sorabji I think I need to make a validation test because 'sometiems' I get error http://pastie.org/10297344
xochilpili
theskillwithin
well ur problem was that the pregmatch wasnt getting the line below it right?
xochilpili I would try stripping out the newlines somehow http://php.net/manual/en/function.trim.php
then var_dump that data and see if you can use ur regex on that
it would be neat if you could strip out the newlines in such a way that each [abc] blah=>blah was on its own line insetad of 2 lines
xochilpili
theskillwithin, yes, i can't get the line below
theskillwithin
then if you can do my seggestion it will work way better
xochilpili
theskillwithin, i did not understand
theskillwithin
your data looks like this:
[abc]
text=>text
make it look like this:
[abc] text=>text
see 1 line
xochilpili
i can't modify the file
theskillwithin
you put the file inside a string right?
you modify the string
xochilpili
do you mean line 3 in my post?
theskillwithin
xochilpili
theskillwithin, but how can i do that? in the file there's an \n
theskillwithin
strip out all newlines
then before each [ add a newline
u dont do it to the file, u do it to the variable you loaded ur file into...
does anyone know how to validate line 2 & 3 so I stop getting notices? http://pastie.org/10297344
if line 2 or 3 is non object then or something
PsychoBoB
Guys
Have a way to get all FK's of the table, via php?
theskillwithin
I am testing for is_object in if statment, but it still gives error! http://pastie.org/10297383">http://pastie.org/10297383
caffinated
theskillwithin: $pxml may be an object, but the items you're accessing inside of it may not be
theskillwithin
caffinated what would be a better way for me to validate this then?
         

caffinated
theskillwithin: you need to confirm that each object you're accessing is an object
theskillwithin
v
if ( !is_object( $pxml->Itmes->Item ) )
caffinated
I think you'll find that may error
this is why a lot of people prefer not to chain objects
theskillwithin
fu*k AWS Access Key ID: **********************. You are submitting requests too quickly. Please retry your requests at a slower rate."
retran
what's that have to do with anything
xochilpili
theskillwithin, i can't make this on one line: http://pastebin.com/
i change $contents=str_replace("\n",$vm);
retran
code golf?
caffinated
xochilpili: that doesn't even make sense. str_replace needs 3 arguments.
theskillwithin
also you just gave us a link to pastebin... not an instance of a paste bin
hey can you check out my code plz! here it is! http://pastie.org/
xochilpili
sorry; http://pastebin.com/ZXB1c7h0
jaja
lol
str_replace("\n",'',$vm);
theskillwithin
caffinated hit the nail on the head probably, u are missing an arguemnt in str_rel[pace
yeah
try using http://php.net/manual/en/function.trim.php
retran
lets invent an str_replace with only 2 arguments
theskillwithin
but but but
but
caffinated
how about you stop ragging on the guy for making a typo
sorabji
can we rag on people that pick common words as nicks instead?
caffinated
it's not like any of us are immune to mistakes like that
retran
people who use adjectative-nouns as nicknames
theskillwithin
what am i supposed to do then!?! get back to work? blah
xochilpili
theskillwithin, i used trim($vm,'\n'); but i got the same result; just [abc]; not in one line
theskillwithin
there might be another indicator for newline other than \n
xochilpili
is the reg_match_all ok?
caffinated
xochilpili: you have to assign trim, and \n doesn't interpolate in single quotes.
retran
http://php.net/manual/en/language.types.string.php#language.types.string.syntax.single
caffinated
you'd want something more like: $vm = trim($vm, "\n");
retran
in programming they call it (informally) the hard-quotes vs. soft-quotes designation
most languages have that
xochilpili
i tried both; trim($vm,"\n"); and trim($vm,"\r");
same result;
retran
trim($vm,"\n\r")
theskillwithin
"\n" (ASCII 10 (0x0A)), a new line (line feed).
is utf-8?
retran
ms newlines
caffinated
theskillwithin: no.
although technically it does exist inside the UTF-8 character set.
retran
none of that should matter with trim... since the default char mask includes "\r" and "\n"
xochilpili
retran
but yeah, if you specify just "\n" as your char mask you'll miss trimming for space, and \r
xochilpili
the same result with trim($vm,"\n\r");
theskillwithin
$str = str_replace(PHP_EOL, '', $str);
xochilpili
file /var/www/soft.conf : ASCII C program text
caffinated
theskillwithin: is this an apache conifguration file?
theskillwithin
idk im just throwing out ideas
retran
trim only takes off the begining and end
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 next »