Click here to Skip to main content
15,308,835 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: Where do people go to discuss PWA development? Pin
jhonaa27-Mar-22 23:52
Memberjhonaa27-Mar-22 23:52 
QuestionWhat are the usage of the req.route() in express ? Pin
Member 1447916115-Feb-22 10:43
MemberMember 1447916115-Feb-22 10:43 
AnswerRe: What are the usage of the req.route() in express ? Pin
jhonaa7-Mar-22 23:15
Memberjhonaa7-Mar-22 23:15 
AnswerRe: What are the usage of the req.route() in express ? Pin
deepok130-Mar-22 21:56
Memberdeepok130-Mar-22 21:56 
QuestionWhy is my last input box not centering (class: powerwall-battery-input)? Pin
WannaBeAWebDev11-Feb-22 14:22
MemberWannaBeAWebDev11-Feb-22 14:22 
AnswerRe: Why is my last input box not centering (class: powerwall-battery-input)? Pin
Richard MacCutchan11-Feb-22 22:34
mveRichard MacCutchan11-Feb-22 22:34 
QuestionWeird HTTP Status code 302 "Moved Temporarily" Pin
#realJSOP3-Feb-22 0:17
mva#realJSOP3-Feb-22 0:17 
QuestionPHP7, build an array and select one array record based on value Pin
jkirkerx24-Jan-22 11:19
professionaljkirkerx24-Jan-22 11:19 
I can't figure this out.

I have an array ...
And I want the array record with the minimum distance of 6, in which I calculated already. I figured PHP7 had a function to just select a record in an array, but I can't find it, or it's done some other way that I'm not familiar with.
Input word: mini-stonescape group iii - Lev Distance: 6 - Shortest: 6
Did you mean: stonescapes group iii

Smallest Distance: 6
array(16) {
  [0]=>
  array(3) {
    ["key"]=> string(10) "REF_PA_365"
    ["value"]=> string(21) "stonescapes group iii"
    ["distance"]=> int(6)
  }
  [1]=>
  array(3) {
    ["key"]=> string(10) "REF_PA_364"
    ["value"]=> string(20) "stonescapes group ii"
    ["distance"]=> int(7)
  }
  [2]=>
  array(3) {
    ["key"]=> string(10) "REF_PA_081"
    ["value"]=> string(19) "stonescapes group i"
    ["distance"]=> int(8)
  }

As far as code goes, well I tried about 10 things with failure. So I deleted all my tries. I have nothing but an array. I just need a nudge, a keyword or something.
// if this distance is less than the next found shortest word
// distance, OR if a next shortest word has not yet been found
if ($distance <= $shortest || $shortest < 0) {
    // set the closest match, and shortest distance
    $closest  = $value;
    $shortest = $distance;
}

echo "Input word: $partDescription - Lev Distance: $distance - Shortest: $shortest\n";
if ($shortest == 0) {

    echo "Exact match found: $closest\n\n";
    $pValue = $closest;

} else {

    echo "Did you mean: $closest\n\n";

    // Analyse the word more in detail
    $distances = array_column($comparisons, 'distance');
    $smallestDistance = min($distances);
    echo "Smallest Distance: $smallestDistance\n";
    var_dump($comparisons);

    // $pValue = $answer['key'];
    // $closest = $answer['value'];
    echo "Best choice: $closest\n\n";
    var_dump($pValue);

}
If it ain't broke don't fix it
Discover my world at jkirkerx.com

AnswerRe: PHP7, build an array and select one array record based on value Pin
jkirkerx24-Jan-22 11:46
professionaljkirkerx24-Jan-22 11:46 
Generalusing web API Pin
Southmountain17-Jan-22 8:44
MemberSouthmountain17-Jan-22 8:44 
GeneralRe: using web API Pin
OriginalGriff17-Jan-22 8:55
mveOriginalGriff17-Jan-22 8:55 
GeneralRe: using web API Pin
Southmountain17-Jan-22 9:00
MemberSouthmountain17-Jan-22 9:00 
GeneralRe: using web API Pin
RickZeeland17-Jan-22 9:56
mveRickZeeland17-Jan-22 9:56 
GeneralRe: using web API Pin
Slacker00718-Jan-22 0:18
professionalSlacker00718-Jan-22 0:18 
GeneralRe: using web API Pin
Southmountain25-Jan-22 6:06
MemberSouthmountain25-Jan-22 6:06 
GeneralRe: using web API Pin
deepok130-Mar-22 21:55
Memberdeepok130-Mar-22 21:55 
GeneralHow can i create social media sharing links for my website? Pin
Vijay Bishnoi15-Jan-22 19:45
MemberVijay Bishnoi15-Jan-22 19:45 
QuestionHow can i create social media sharing links for my website? Pin
Vijay Bishnoi15-Jan-22 19:45
MemberVijay Bishnoi15-Jan-22 19:45 
QuestionWhat is program is better to use than Dreamweaver for Website Design? Pin
David Mills 202112-Jan-22 21:44
MemberDavid Mills 202112-Jan-22 21:44 
AnswerRe: What is program is better to use than Dreamweaver for Website Design? Pin
RobertSF25-Feb-22 12:46
professionalRobertSF25-Feb-22 12:46 
QuestionPHP quota on server Pin
JR21225-Dec-21 23:45
MemberJR21225-Dec-21 23:45 
Questiongreating Pin
BEBEL AZOO20-Dec-21 20:03
MemberBEBEL AZOO20-Dec-21 20:03 
AnswerRe: greating Pin
Connie Rucker21-Dec-21 3:00
MemberConnie Rucker21-Dec-21 3:00 
QuestionWeb Server on Linux Pin
#realJSOP14-Nov-21 2:39
mva#realJSOP14-Nov-21 2:39 
AnswerRe: Web Server on Linux Pin
markkuk14-Nov-21 23:21
Membermarkkuk14-Nov-21 23:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.