Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8341235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:25:10+00:00 2026-06-09T05:25:10+00:00

So, here’s my situation : I’m using CodeIgniter I’ve set up a helper, (‘string_helper’

  • 0

So, here’s my situation :

  • I’m using CodeIgniter
  • I’ve set up a helper, (‘string_helper’ under ‘DK’ folder)
  • I’ve set up the dkString class in dk/string_helper.php

    static function strInArray($str,$arr)
    {
          foreach ($arr as $item) 
          {
                if (self::inString($str,$item))
                      return true;
          }
    
          return false;
    }
    
  • In my controller:
    • I’m loading the helper ($this->load->helper('dk/string');)
    • Calling the method (dkString::strInArray($str,$arr);)

Note :

  • I’ve loaded class’s static methods residing in a custom helper, like 100 times. So there’s nothing wrong with it.
  • It doesn’t matter whether the function is declared as static or not. Normally it works, no matter what.

However, I keep getting the following error :

Fatal error: Call to undefined method dkString::strInArray() in
/the/path/to/the/caller/file.php on Line XX

Any ideas what might be wrong?


<?php

/*
 * DK4PHP Library
 *
 * Copyright (c) 2010-2012 by Dr.Kameleon
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

if (!class_exists('dkString'))
{
    class dkString
    {
    /**
     * Return number of character in string
     * 
     * @param type $str
     * @return type 
     */

    function characterCount($str)
    {
        return strlen($str); 
    }

    /**
     * Check if str begins with...
     * @param type $str
     * @param type $sub
     * @return type 
     */

    function beginsWith($str, $sub)
    {
        return (substr($str,0,strlen($sub)) == $sub);
    }

    /**
     * Check if str ends with...
     * 
     * @param type $str
     * @param type $sub
     * @return type 
     */

    function endsWith($str, $sub)
    {
        return (substr($str,strlen($str)-strlen($sub)) == $sub);
    }

    /**
     * Check if str contains substring
     * 
     * @param type $sub
     * @param type $str
     * @param type $casesensitive
     * @return type 
     */

    function inString($sub, $str, $casesensitive = false)
    {
        if ($casesensitive)
        return (strstr($str, $sub) == false) ? false : true;
        else
        return (stristr($str, $sub) == false) ? false : true;
    }

    /**
     * Count number of occurences of substring in string
     * 
     * @param type $sub
     * @param type $str
     * @return type 
     */

    function inStringCount($sub, $str) 
    {
        return substr_count($str, $sub);
    }

    /**
     * Convert string to number
     * 
     * @param type $str
     * @param type $check
     * @param type $magic
     * @return type 
     */

    function strtonum($str, $check, $magic)
    {
        $int32Unit = 4294967296;

        $length = strlen($str);
        for ($i = 0; $i < $length; $i++)
        {
        $check *= $magic;
        if ($check >= $int32Unit)
        {
            $check = ($check - $int32Unit * (int) ($check / $int32Unit));

            $check = ($check < -2147483648) ? ($check + $int32Unit) : $check;
        }
        $check += ord($str{$i});
        }
        return $check;
    }

    /**
     * Get index of str in array (check if is contained)
     * 
     * @param type $str
     * @param type $arr 
     */

    function indexInArray($str,$arr)
    {
        foreach ($arr as $index=>$item)
        {
        if (stristr($item,$str))
        {
            return ($index+1);
            break;
        }
        }
        return -1;
    }

    /**
     * Check if str is contained in any of array's elements
     * 
     * @param type $str
     * @param type $arr
     * @return boolean 
     */

    function strInArray($str,$arr)
    {

        foreach ($arr as $item) 
        {
            if (self::inString($str,$item))
                return true;

        }

        return false;
    }
    }
}
?>

UPDATE :

In my controller, after loading the helper ($this->load->helper('dk/string');), I tried :

if (class_exists('dkString')) { echo "IT EXISTS<br/>Methods : "; print_r(get_class_methods('dkString')); }
else echo "IT DOESN'T EXIST";

The “funny” thing is that the output was :

IT EXISTS
Methods : Array ( 
[0] => characterCount 
[1] => beginsWith 
[2] => endsWith 
[3] => inString 
[4] => inStringCount 
[5] => strtonum 
[6] => indexInArray )

In a few words : the class IS loaded, and it “sees” ALL methods (except for the last one). Geezz… :/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:25:11+00:00Added an answer on June 9, 2026 at 5:25 am

    Try to make a “public” function.

    public static function strInArray($str,$arr) {
        foreach ($arr as $item) {
            if (self::inString($str,$item))
                return true;
        }
    
        return false;
    }
    

    Edit: Its possible that your interpreter can’t find the class. Then he can’t find the static method. Perhaps you can check with class_exists wheather the class is there and loaded.

    Edit2:
    You have to declare you function as static function. Otherwise you cannot call the function with the static operator(::).

    http://php.net/manual/de/language.oop5.static.php

    So no one is in chat… but the error message is really clear. You try to call a static function but that function is not a static function so you get the message you get on top.

    Otherwise call them as a function over an instance

    $dkString = new dkString;
    $res = $dfString->strInArray();
    

    Perhaps its easier when you use internal functions like in_array to find a string in an array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my situation: I have a Data Template set up which contains a ToggleButton
here's a conundrum for you, Using Django 1.4, I cannot get messages set through
Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }
Here is what I am currently doing. PHP echo's out the recent post in
Here is the script I'm using, copied directly from Google: <script type=text/javascript> var _gaq
Here my problem: @Assert\Regex( * pattern=/^[A-Za-z0-9][A-Za-z0-9\]*$/, * groups={creation, creation_logged} * ) I'm using the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
here is my php code $titikPetaInti = array(); while($row = mysql_fetch_assoc($hasil2)) { $titikPetaInti[] =
Here is the code I'm using inside my AsyncTask DefaultHttpClient httpClient = new DefaultHttpClient();
Here is my class: public class A{ private void doIt(int[] X, int[] Y){ //change

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.