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

Web Development

 
AnswerRe: What are the usage of the req.route() in express ? Pin
jhonaa7-Mar-22 23:15
jhonaa7-Mar-22 23:15 
AnswerRe: What are the usage of the req.route() in express ? Pin
deepok130-Mar-22 21:56
deepok130-Mar-22 21:56 
QuestionWhy is my last input box not centering (class: powerwall-battery-input)? Pin
WannaBeAWebDev11-Feb-22 14:22
WannaBeAWebDev11-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
mve#realJSOP3-Feb-22 0:17 
AnswerMessage Closed Pin
4-Jul-22 16:45
Member 150787164-Jul-22 16:45 
GeneralRe: Weird HTTP Status code 302 "Moved Temporarily" Pin
#realJSOP4-Jul-22 23:41
mve#realJSOP4-Jul-22 23:41 
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
Southmountain17-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
Southmountain17-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
Southmountain25-Jan-22 6:06 
GeneralRe: using web API Pin
deepok130-Mar-22 21:55
deepok130-Mar-22 21:55 
GeneralHow can i create social media sharing links for my website? Pin
Vijay Bishnoi15-Jan-22 19:45
Vijay Bishnoi15-Jan-22 19:45 
QuestionHow can i create social media sharing links for my website? Pin
Vijay Bishnoi15-Jan-22 19:45
Vijay 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
David 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 
AnswerRe: What is program is better to use than Dreamweaver for Website Design? Pin
Member 150787164-Jul-22 18:53
Member 150787164-Jul-22 18:53 
QuestionMessage Removed Pin
31-Dec-21 3:16
Member 1548518431-Dec-21 3:16 
QuestionPHP quota on server Pin
JR21225-Dec-21 23:45
JR21225-Dec-21 23:45 
Questiongreating Pin
BEBEL AZOO20-Dec-21 20:03
BEBEL AZOO20-Dec-21 20:03 
AnswerRe: greating Pin
Connie Rucker21-Dec-21 3:00
Connie Rucker21-Dec-21 3:00 

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.