Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

feet and inches to inches

Posted on 2013-11-24
3
351 Views
Last Modified: 2013-11-25
turn this feet-inches to inches conversion
$inches = current(explode("'", $height)) * 12 + end(explode("'", rtrim(trim($height), '"')));

to

an object oriented method (not just a procedural function) that accepts feet-inches as a parameter and returns inches
0
Comment
Question by:rgb192
  • 2
3 Comments
 
LVL 20

Accepted Solution

by:
Mark Brady earned 500 total points
ID: 39673581
I think you have already asked this in another question however if you want this done in an object class you just pout it inside a function. Here's a quick example.

<?php

// instantiate the class object
$convert = new Conversion();

// call its run method (function)
$length = "6'3''"; // 6 foot 3 inches

$inches = $convert->feet_to_inches($length);

var_dump($inches);


// the end.....

class Conversion {
    
        
    public function feet_to_inches($length) {
        // explode the string
        $temp = array_map('trim', explode("'", $length));
        
        return ($temp[0] * 12) + $temp[1];
    }
}

?>

Open in new window

0
 

Author Closing Comment

by:rgb192
ID: 39673588
that addition temp[0] (feet) + temp[1] inches makes code easy to understand

thanks
0
 
LVL 20

Expert Comment

by:Mark Brady
ID: 39675417
You're welcome
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How can I make this form submit to itself? 10 35
Dynamic Dropdowns 15 32
reverse engineer .sql from php files 11 33
JQuery Search Filter 2 27
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question