logs archiveIRC Archive / Freenode / #php / 2015 / September / 24 / 1
_Th1nKT4nK_
I need a php manual
Alphos
_Th1nKT4nK_ php.net/manual/en/index.php for instance
_Th1nKT4nK_
Cool Alphos
;-)
I want to see if I can have something on print too& or pdf
Alphos
_Th1nKT4nK_ http://docs.php.net/docs.php
matkatmusic
what's the proper way to convert a json subarray to a string?
TML
matkatmusic: What do you mean?
matkatmusic
i'm trying to parse some json thats' like { "a":1, "b":2", "c": { "abracadabra":65, "bamboozled":99"} }
i want to split up the 'c' subarray
TML
as long as it's well formatted json, do: $data = json_decode(...); and then do whatever you want done using $data['c']
Woet
matkatmusic: thats not valid JSON
         

matkatmusic
@TML so $data = $json_decode( $data['c'], true ); ?
Woet
matkatmusic: no, your actual JSON instead of $data['c'].
matkatmusic
i'm just reusing the $data
Woet
matkatmusic: there's no need to run json_decode twice.
matkatmusic: unless you have json within your json.
matkatmusic: why don't you just share your actual JSON and actual code with us?
NoiseEee
why don't you just var_dump your json_decode($allTheJSON) and examine it
why don't you just tell me the name of the movie you want to see
Woet
NoiseEee: the martian
AcousticDan
Woet doesn't get it
NoiseEee
Woet: man i hope thats as good as the previews
TML
the novel was pretty great
valeech
Hello. I am having trouble getting the php5-redis extension to load. I am trying to install v2.2.7. I am on ubuntu 14.04 and I used the following commands to install: apt-get install php-pear php5-dev / pecl install redis / php5enmod redis / service apache2 restart Now if I do php --ri redis I get Extension 'redis' not present. Any ideas what I am missing?
matkatmusic
http://pastebin.com/LJd5idPA Woet
Woet: how do i parse the 'purchase' subarray of json?
AliG1000
Hi = in this array, how can I find 'Routes'? https://3v4l.org/6mNNt
Woet
matkatmusic: you removed the comments right?
matkatmusic: http://viper-7.com/9OD5zI
matkatmusic
that's not the actual json i'm working with, but it follows that format
TML
matkatmusic: What do you mean "parse"?
you don't normally "parse" an array
matkatmusic
if I foreach() with that json, when it hits 'purchase', i get warnings that say it's an array, and not a string and therefore won't echo
Woet
matkatmusic: so where is your actual code?
TML
valeech: Try "php5enmod -s ALL redis"
matkatmusic: So you want to echo some value in the array?
valeech: php --ri only queries the CLI SAPI, not the Apache2 SAPI
matkatmusic
kenneth24
what does json_decode() return??
         

laszlof
mother of god.
Woet
(Action) blinks
AliG1000
I have tried 'array_search' but it doesn't appear to work in multi-level arrays
TML
matkatmusic: Don't do json_decode() on something that has already been through json_decode
Woet
matkatmusic: you know you can just use $json['purchase']['email'], right?
matkatmusic
I did not know that
kenneth24
Rice bubbles time!!!
You specify the index by doing this
Woet
valeech
TML: Thanks. I tried the php5enmod -s ALL redis and then the php ri redis again and still no extension
Woet
matkatmusic: next time, please just show your code and ask your question instead of asking all these weird questions that make no sense
NoiseEee
kenneth24
Asking questions is an art.
TML
AliG1000: foreach($haystack as $child) { array_search($needle, $child) & }
AliG1000
NoiseEee: I tried exactly that on this array https://3v4l.org/K4ZH6 no dice. I couldn't get the key for Routes
TML
valeech: ls -al `pecl config-get ext_dir`/*
AliG1000
@TML: I will give that a whirl
TML
valeech: Do you see a thing named "redis.so" there?
NoiseEee
AliG1000: weird array dude
AliG1000: your array is *supposed* to have keys like "url","text", and "0" ?
valeech
TML: This cant be good: No such file or directory
TML: pecl config-get ext_dir returns /usr/lib/php5/20121212+lfs Now that directory doesnt exist but /usr/lib/php5/20121212 does and redis.so is in there
TML
valeech: There's your problem
valeech
TML: not to come off as a total n00b but any idea how I fix that :)
TML
valeech: What does phpinfo() in your running PHP say for extension_dir?
AliG1000
NoiseEee well, I am trying to put together breadcrumb navigation. An array looks like it is the way (or at least one way) to go. I can use the array to reflect the directory structure. Or at least that is the theory
valeech
TML: extension_dir => /usr/lib/php5/20121212 => /usr/lib/php5/20121212
AliG1000
NoiseEee: On each page, I can tell the script which page it is on - which then checks the array, and tells me the parent directory - and using this I can write the breadcrumb navigation
TML
valeech: php -dextension=redis.so -r 'var_dump(function_exists("some function defined by the redis module"));'
valeech
TML: bool(false)
AliG1000
it would be genius if only I could get it to work :)
NoiseEee
AliG1000: i'd look into established patterns for breadcrumb navigation before writing your own, fwiw
TML
valeech: What did you use as the function name?
valeech
TML: oh, oops
TML
valeech: I don't know redis at all, so you'll have to supply some of the details of what you're expecting to see :)
valeech
TML: fair enough :)
TML: I am not really sure what I am looking for either. A package I am using requires redis. I looked for a few functions and I continue to get false returned
TML
valeech: php -dextension=redis.so -r 'var_dump(module_loaded("redis"));'
valeech: Are you getting any other errors?
valeech
TML: PHP Fatal error: Call to undefined function module_loaded() in Command line code on line 1
TML
shoot
what's the name of that thing
valeech
TML: no other errors. I am hoping this isnt a peel back the onion exercise :)
TML
extension_loaded
not module_loaded
valeech
ok
bool(true)
TML: php -dextension=redis.so -r 'var_dump(extension_loaded("redis"));'
TML
ok, so redis is loading via the CLI
valeech
ok
TML
valeech: What about <?php var_dump(extension_loaded("redis")); in a browser?
valeech
let me set that up
caffinated
problem with redis is there's a lot more than one client. it might be problematic to know which one it's after without looking at the code
valeech
TML: bool(false)
TML
valeech: so find the place where phpinfo() in a browser says your php.ini is loading from, and add "extension=redis.so" to the bottom and then stop/start apache
valeech
TML: ok
TML: bool(true) :)
TML: BOOM! Everything working again. Thank you so much!
donguston
is it dumb to code load balancing into an application or should my infrastructure under the application handle it?
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 next »