Jump to content


Member Since 24 May 2006
Offline Last Active Apr 17 2013 04:09 PM

Topics I've Started

JQuery load php in div INCLUDING arguments

07 April 2013 - 09:42 PM

I've searched everywhere and just can't seem to find my answer, so here:


I'm powerful with php and that I can deal with, but I never really had the chance to develop my javascript skills. I want to use JQuery to load part of a page in a container div. The problem is every tutorial I check out, the target (or result) div where the content will load is already defined in the function. Is there a way to include 2 arguments like this : (pseudo-code, I don't know the real syntax, still a newb at JQuery)

function ajaxpage(url, containerid){
   // do the magic here
// and calling the page

<a href="javascriptTheJQueryWayHere:ajaxpage('page.php?id=12','load_in_this_div')">link</a>

<div id="load_in_this_div"></div>

I don't necessarily want a baked answer, just any link to any resource except RTFM would be of great help!

Does @font-face load ALL fonts in ONE browser

07 April 2013 - 08:16 AM

Hey everyone,

I've been starting to use @font-face in the last year or so seeing that most major browsers support it now. I usually just use 1-3 fonts max, but most often I include the italics version, bold and italic bold version, which can easily amount to a couple MBs of data minimum (depending on the font). Since I use EOT, TTF, WOFF and SVG to work in most browsers, the filesize augments. I don't want too much bandwidth (and load time) used, especially when it's not absolutely necessary upon the customer's request, so I was wondering : say if Firefox (or any browser) successfully loads the EOT version of the file, will that browser still download all 3 others or it will specifically ignore the rest? If it does ignore the rest (not download them) then bandwidth would be much less of an issue.

I know some of you might say "well, bandwidth nowadays...", but I still prefer to keep things minimal by habit.

REGEXP - anything, including space

15 August 2012 - 08:16 PM

Hey everyone.

So I want to be able to find "John Bee Doe" when the user input is "John Doe". I'm using REGEXP because I'm already using what I call $name_similes containing an array of similar names (ex.: Britney, Britanny, etc).

I'm stuck on this part though (John Bee Doe). I tried using REGEXP imploding on spaces after each word (search term) to replace with ([[:alpha:]]|[[:space:]]) which I assumed would include either a space, but it doesn't work. Anybody hae any advice or ideas ?

sprintf-like for variable-only purposes without printing

04 February 2012 - 06:26 PM

Hey everyone,

I've come around this problem quite a few times now, so I'm looking for a cleaner way to do what I always resort to. Here's my scenario:

The following line is fairly straightforward:

$sql_where = " WHERE SUBSTRING(name,1,1) = '".$c."' ";

But sometimes I need to explode on some values, rising a need for multiple instances of the above, as in MYSQL's WHERE bla = 1 || WHERE bla = 2 || WHERE bla = 3

Of course, I could always write it out manually, like this:
foreach($c as $v) {
   $sql_str .=  "WHERE SUBSTRING(name,1,1) = '".$v."' ";

But I want my code to be more modular. The only solution I've been using so far is something like this:
$where_start = "WHERE SUBSTRING(name,1,1) = '";
$where_end = "' ";
foreach($c as $v) {
   $sql_str .= $where_start . $v . $where_end;

I find this technique a bit ridiculous and I was wondering if there was a similar method as say when you want to sprintf like this:

$v = 'Bla bla %s bla';
sprintf($str, $v);

So my question is basically this: is there any way to use a sprintf-like function that will concatenate variables inside variables?

Thanks for any suggestions or input.

Preg_Match_All for filepaths

02 December 2011 - 04:36 AM

Hi everyone,

I'll include some details, as I've just read the sticky and really want to respect the guidelines. This is a PCRE (preg) flavor regex, as suggests preg_match_all() which I wish to use.

And foremost: I am not someone seeking for a cooked answer (although I wouldn't refuse it). Any guidance into the accomplishment of my required regex will be greatly appreciated, hints, explanations. The reason is I'm a pretty good programmer at php, but I suck at regex, although I know I'll have to catch up on it one day.

My problem: (and some contextual background, as per the *sticky* instructions)
I am working on a file analyser, Mixcraft (a DAW) files to be precise. The "problem" in Mixcraft is that one can COPY project files (WAV/OGG/etc) to a new location, with no MOVE option, as to delete the old unused files. Of course, what I did (manually) for years was just make a list on notepad to then skim through my harddrive for these filenames and delete them one by one, and some filenames are hard to discern from within that program when they are cross-faded (musical term) into others and cut short... to make it simple: I wanted a simple (php-based) solution to upload that project file which contains references to the sound files (mostly WAVs) in a string fashion, scattered amongst the gibberish characters one might expect from opening a desktop file that is generated to be interpretted by a desktop application (probably programmed in C# or something). I'll give you a glimpse of the file I am trying to read, replacing the gibberish characters with question marks because they seem to parse improperly when pasted here

Short file sample:

????????????????????????????????????????????????????????????????C:\Documents and Settings\neuroxik\My Documents\My Recordings\01 Audio
??????????????????????????????????????????????\..\..\..\..\Catch Me\bounce-track 01 6-3-2011 ID3.WAV?????????????????????

I've highlighted the searched strings above in red. What I want is a list (preferably in an array, that's why I chose preg_match_all and to find ALL occurences) of the file paths found in these files. I've been working and still will work on the rest, but I'm stuck on the regex part. Here are some important points:
  • They're ALWAYS (Windows) filepaths, either relative (like the second one above) or absolute.
  • More than one (or none at all) filepaths can be found per line
  • A filepath can start on one line and end on the other, as between lines 1 and 2 in my example above
  • The file extention at the end needs to be case-insensitive (WAV|wav) and if possible, if I can use an array of predetermined file extensions, such as WAV, OGG, MP3, etc
  • The drive letter is not bound to be C, but can be, when the filename happens to be absolute
  • If this is too complicated, I would be VERY HAPPY even if I can only match on something like this: \Audio File.wav (backslash, filename which may include numbers, letters, spaces, apostrophes and some "legal filename characters", followed by a dot and an array of wav|ogg|mp3 file extension)

If any further data or code is needed to help me, just tell me, I am more than grateful for any suggestions, hints, code snippets or "how to's".... Thanks in advance! Alot!

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime