473,394 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

filtering xdebug ini keys

I've created the following function for returning only ini keys that
pertain to xdebug. I'm wondering how I might go about doing the same
sort of thing with one or more of the various "array_" functions
instead (e.g. array_filter). Since I'm working with xdebug (if you
can't tell ;) I'll respond in kind with trace data comparing the
functions.

Thanks in advance....George Jempty

function ini_get_xdebug() {
$ini_all = ini_get_all();
$ini_xdebug = array();
$xdebug_prefix = 'xdebug.';

foreach ($ini_all as $k=>$v) {
if (substr($k, 0, strlen($xdebug_prefix)) == $xdebug_prefix) {
$ini_xdebug[substr($k, strlen($xdebug_prefix))] = $v;
}
}
return $ini_xdebug;
}

Oct 28 '07 #1
3 1571
On Oct 28, 8:53 am, jemptymethod <jemptymet...@gmail.comwrote:
I've created the following function for returning only ini keys that
pertain to xdebug. I'm wondering how I might go about doing the same
sort of thing with one or more of the various "array_" functions
instead (e.g. array_filter). Since I'm working with xdebug (if you
can't tell ;) I'll respond in kind with trace data comparing the
functions
Interesting trace data already....by moving the calls to
strlen($xdebug_prefix) outside the loop, I reduce execution time from
over 15 milliseconds to under 10
Thanks in advance....George Jempty

function ini_get_xdebug() {
$ini_all = ini_get_all();
$ini_xdebug = array();
$xdebug_prefix = 'xdebug.';

foreach ($ini_all as $k=>$v) {
if (substr($k, 0, strlen($xdebug_prefix)) == $xdebug_prefix) {
$ini_xdebug[substr($k, strlen($xdebug_prefix))] = $v;
}
}
return $ini_xdebug;
}

Oct 28 '07 #2
On Sun, 28 Oct 2007 13:53:34 +0100, jemptymethod <je**********@gmail.com
wrote:
I've created the following function for returning only ini keys that
pertain to xdebug. I'm wondering how I might go about doing the same
sort of thing with one or more of the various "array_" functions
instead (e.g. array_filter). Since I'm working with xdebug (if you
can't tell ;) I'll respond in kind with trace data comparing the
functions.

Thanks in advance....George Jempty

function ini_get_xdebug() {
$ini_all = ini_get_all();
$ini_xdebug = array();
$xdebug_prefix = 'xdebug.';

foreach ($ini_all as $k=>$v) {
if (substr($k, 0, strlen($xdebug_prefix)) == $xdebug_prefix) {
$ini_xdebug[substr($k, strlen($xdebug_prefix))] = $v;
}
}
return $ini_xdebug;
}
What you should be doing:

$ini_xdebug = ini_get_all('xdebug');

To answer your question, something like (untested):

<?php
function _is_xdebug($string){
return preg_match('/^xdebug/i',$string);
}
$all = ini_get_all();
$keys = array_keys($all);
$neededkeys = array_filter($keys,'_is_xdebug');
$xdebug = array_intersect_key($all,array_flip($neededkeys));
?>
--
Rik Wasmus
Oct 28 '07 #3
On Oct 28, 9:28 am, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
>
To answer your question, something like (untested):

<?php
function _is_xdebug($string){
return preg_match('/^xdebug/i',$string);}

$all = ini_get_all();
$keys = array_keys($all);
$neededkeys = array_filter($keys,'_is_xdebug');
$xdebug = array_intersect_key($all,array_flip($neededkeys));
?>
For "untested" that worked out of the box ;) Thanks very much for the
lesson on how to use these array_ functions.

My very first trace however indicates 17 milliseconds. And replacing
the regular expression with 0===strpos($string, 'xdebug') didn't even
save a 10th of a millisecond (0.016824 vs. 0.016918).
Oct 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: kevinold | last post by:
Hello everyone, I have a list of about 1600 employees that I'd like to have displayed in a form. I'd like to make the "search" for the user as easy as possible. I ran across this:...
0
by: Devin Brume | last post by:
Have and application that is error free with the exception of a proble with xdebug generating the following errors: xdebug is a MS file, ho do I fix this issue. c:\Program Files\Microsoft...
7
by: Ryan | last post by:
I have a DataGridView which displays numeric (Int32) data from an underlying database. I want the numbers to be displayed in numeric format "#,###" (with commas). I want to also limit the user so...
0
gauravgmbhr
by: gauravgmbhr | last post by:
Hi friends i have heard Bout Xdebug that helps telling imformation about code coverage ie how much PHP code is covered during the compilation and run time This code coverage feature is very...
1
by: R.A.M. | last post by:
Hello, I have installed (in Windows XP) Apache, PHP5, XDebug and Eclipse PDT. Then I configured XDebugging according to:...
0
by: Sean Quinn | last post by:
Hi All, First off let me say that from what I've seen of the XDebug debugger, I'm pretty impressed--it would just be nice if I could actually use it to its full potential in Eclipse. My...
1
by: r_ahimsa_m | last post by:
Hello, I am learning PHP5 in Fedora Linux. I have installed xdebug and Quanta+ editor. Could you tell me please how to start debugging. I can't find description in Internet. THANX /RAM/
3
by: =?iso-8859-1?Q?Johnny_J=F6rgensen?= | last post by:
I've got a textbox where I filter the input in the KeyPress event to allow only certain characters. However, If the user cuts and pastes a text into the textbox, all text is entered - not only...
0
by: r_ahimsa_m | last post by:
Hello, I use PHP5 in Fedora Linux with QuantaPlus 3.5. Recently I downloaded xdebug, installed it in /opt/xdebug-2.0.3, then I compiled it and I added valid line...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.