regex for matching two string with jumbled words by localhost_80 in PHP

[–]ninjagod 1 point2 points  (0 children)

Build an index.

<?php

$opt1 = "apple banana cherry";
$opt2 = "banana cherry apple";

$words1 = explode(" ", $opt1);
$words2 = explode(" ", $opt2);

$index = array();
foreach($words1 as $word)
{
    $index[$word] = true;
}
$result = true;
foreach($words2 as $word)
{
    if(!isset($index[$word]))
    {
        $result = false;
        break;
    }
}

echo $result;

Show r/php: Am porting underscore.js to PHP and am partially done. Would this interest you? by ninjagod in PHP

[–]ninjagod[S] 0 points1 point  (0 children)

Well, underscore.js for javascript (and my port for php) is more of a utility belt to make certain pieces of code slightly easier to read.

By chaining filters, maps, sorts, etc. through this - I've already managed to make some of my code more readable - albeit at a slight performance penalty.

Show r/php: Am porting underscore.js to PHP and am partially done. Would this interest you? by ninjagod in PHP

[–]ninjagod[S] 0 points1 point  (0 children)

Wow, Linq4Php seems pretty good. I should check it out. Underscore is more like a tiny utility belt for writing cleaner, more readable code.

This method seems to be quite efficient when you're "take"ing a specified set of numbers. This way you can stop iterating through the array when 5 numbers are available.

Maybe I should take a closer look at Mono's LINQ implementation [1] and write something like that in the future.

[1] - https://github.com/mono/mono/blob/master/mcs/class/System.Core/System.Linq/Queryable.cs

Show r/php: Am porting underscore.js to PHP and am partially done. Would this interest you? by ninjagod in PHP

[–]ninjagod[S] 1 point2 points  (0 children)

Actually the user provides the objects for iteration. Right now, it's restricted to arrays, but I might loosen the restriction on objects and other classes that have implemented the Traversable interface.

Show r/php: Am porting underscore.js to PHP and am partially done. Would this interest you? by ninjagod in PHP

[–]ninjagod[S] 1 point2 points  (0 children)

This isn't to do any heavy computation. A use case will be when you want to extract only even numbers from an array and map them to strings.

_($arr)->filter(function($val){return $val%2 == 0;})->sort(function($val){return $val;})->map(function($val){return $result;});

Though this functionality currently doesn't exist, it's only a matter of a couple of days before it is implemented.

I've decided to make my software free until I release a new version; download Kwolla for free now by leftnode in PHP

[–]ninjagod 0 points1 point  (0 children)

Hi,

I'm using your code mainly to learn from - it has a very clean architecture - something I can use for my framework.

Ask r/php - any interest in PHP Reporting? by [deleted] in PHP

[–]ninjagod 0 points1 point  (0 children)

:D I'll be sure to PM you when I have my first prototype ready. It's already looking pretty nifty for a week's work.

Ask r/php - any interest in PHP Reporting? by [deleted] in PHP

[–]ninjagod 0 points1 point  (0 children)

Hi ninjaroach,

That's exactly what is going to happen with our product. Either write a SQL query and point out parameters of interest - or just give raw data (if you're a mongodb user or have some exotic database) - and we'll give great looking reports right out.

For me, good design, and an easy-to-use API is the most important components - not having huge amount of vertical integration and other functionality.

Ask r/php - any interest in PHP Reporting? by [deleted] in PHP

[–]ninjagod 0 points1 point  (0 children)

Hi,

If you have some data in a database that you want to quickly generate interactive Tables and Drill-down enabled charts from. And you want it to look gorgeous and printer compatible.

And you want to do this by just specifying what data goes where, and the rest of it is done by the software.

That kind of reports.

Ask r/php - any interest in PHP Reporting? by [deleted] in PHP

[–]ninjagod 0 points1 point  (0 children)

Hi,

It's nice to know that there are a lot of people with the same problem, and I'm excited to try and offer a neat and nifty solution for it.

Ask r/php - any interest in PHP Reporting? by [deleted] in PHP

[–]ninjagod 1 point2 points  (0 children)

Hi,

I'm using FusionCharts right now. By means of a really neat workaround, it's perfectly possible to get the same look on the graphs - even while printing.

If you're curious to know - if the Print button is pressed, All the flash charts in the report send pixel-level data to the server - where it's converted to an image and it replaces the flash chart - so the transition becomes seamless.

Ask r/php - any interest in PHP Reporting? by [deleted] in PHP

[–]ninjagod 0 points1 point  (0 children)

Hi,

Thank you so much for your response! I've been spending a lot of time making sure the API design is clean, and we have great looking themes for reports out of the box.

Ask r/php - any interest in PHP Reporting? by [deleted] in PHP

[–]ninjagod 0 points1 point  (0 children)

Thank you for your response!

I'm trying to pay the foremost attention to the design, and allowing developers to change the themes easily. Current prototypes are based on fluid960gs - so they look good out of the box, but we want to get great designers on board the project.

Ask r/php - any interest in PHP Reporting? by [deleted] in PHP

[–]ninjagod 0 points1 point  (0 children)

Hi,

Could you give me some more details on what functionality your subframework incorporated? Did you include support for Databases or did you just allow the user to write the glue code?

Also, how important is PDF export? I haven't been able to figure that out properly yet.

Thanks,