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 7959565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:35:37+00:00 2026-06-04T04:35:37+00:00

I have a form, and the URL is like this: http://hostname/projectname/classname/methodname/variablename And in my

  • 0

I have a form, and the URL is like this:

http://hostname/projectname/classname/methodname/variablename

And in my JavaScript, I fill an array like this:

var currentrelations = new Array();
    $(".ioAddRelation").each(function(index) {
        currentrelations[index] = $(this).html();
    });

And this array has two values ['eeeeee','eeeeee']

So the url is:

http://localhost/Mar7ba/InformationObject/addIO/eeeeee,eeeeee

And in my PHP, in the class InformationObject, on the method addIO:

public function addIO($currentRelations =null) {
        $name = $_POST['name'];
        $type = $_POST['type'];
        $concept = $_POST['concept'];
        $contents = $_POST['contents'];
        $this->model->addIO($name, $type, $concept, $contents);
        if (isset($_POST['otherIOs'])) {
            $otherIOs = $_POST['otherIOs'];
            $this->model->addOtherIOs($name, $otherIOs);
        }
        $NumArguments = func_num_args();
        if ($currentRelations!=null) {
            $IOs = $_POST['concetedIOs'];
            $this->model->setIoRelations($name,$IOs, $currentRelations);
        }
        exit;
        include_once 'Successful.php';
        $s = new Successful();
        $s->index("you add the io good");
}

But when I print the array $currentRelations using this statement:

echo count($currentRelations)

The results was 1 not 2, and when I print the first element using thie statement echo $currentRelations[0] I get e not eeeeee

why is that? What is the solution? What am I doing wrong?

  • 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-04T04:35:38+00:00Added an answer on June 4, 2026 at 4:35 am

    As I commented, the $currentRalations is a string, so using count on any type which is not an array or an object will return 1.
    Also, note that when you do this $currentRelations[0] on a string, you are accessing a character in the zero-based index of the string. As strings are arrays of characters you can use the square array brackets to access specific chars within strings. This is why echo $currentRelations[0]; printed e in your code.

    To split a string you should use the explode function like this:

    $curRel = explode(',', $currentRelations);
    

    and then see what you get

    var_dump($curRel);
    

    Hope it helps.

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

Sidebar

Related Questions

I have an iframe with parameters inside the src url like this: <iframe src=http://www.form-page.com?suppressRedirect=1&A=1841
I have a simple form that looks like this: <%= simple_form_for @study,:url => studies_path,
I have a Form element: $Form=new Zend_Form; $Form->setAction($this->view->url(array('controller'=>'auth','action'=>'create'),null,true)) ->setMethod('post') ->setAttrib('id','auth-form') ->removeAttrib('enctype'); As can be
I have a string that contains a url which looks like this: http://www.test.com/images/tony 's
I have a web service I'm trying to hit, URL looks like this: http://servername/webapp/ws/invoices/{invoiceid}
I have a url that looks like this: http://localhost/store/mens/category/t-shirts/item/a-t-shirt I have a class called
I have a search form like this: <form action=@Url.Action(Search, Items, null, null) method=POST> <input
I have form like this: <form method=POST action=<?php echo base_url() ?>admin/admin_search> <fieldset> <label for=nalozi>Nalozi</label><input
I have a simple form that looks like so <% remote_form_for post, :url =>
I have this ajax event function save_response_with_ajax(t){ var form = $('#edit_'+t); var div =

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.