Jump to content

Two Question: string lenght? and query problem.


onedumbcoder

Recommended Posts

Hi Guys,

 

Is there a way to find out what the length of a variable is without counting the spaces in php?

 

for example $s = " Hell o There";

 

And also I am still looking to see if anyone can tell what is wrong with this query

 

i dont know why this query will not work

 

$query = "SELECT * FROM collection WHERE SUBSTRING(word,-4,1) = SUBSTRING('" . $word . "', -4,1) ";

 

SELECT * FROM collection WHERE SUBSTRING(word, -4,1) = SUBSTRING('Hello', -4,1) ORDER BY row
Link to comment
Share on other sites

First question: I'm sure there's a better way than this, but:

<?php
$s = " Hell o There";
$a = explode(" ", $s);
$a = implode("", $a);
$a = strlen($a);
echo $a;
?>

 

2nd question:

 

Okay, this is the 3rd time you have asked the same thing.  Personally I think the first question was a thinly veiled attempt to pass your question off again.  If you cannot follow the rules, action will be taken against you.

 

Thread closed.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.